import { Secret } from '../../Secret'; import { SigningWallet, SerializeOptions } from '../SigningWallet'; import type { WalletSerialized } from '../../WalletSerialized'; import { DerivedKey } from '../../DerivedKey'; import { DerivedPublicKey } from '../../DerivedPublicKey'; /** A cached derivation result for a specific path. */ export interface DerivationIndexEntry { derivationPath: string; xpub: string; /** Compressed public key as hex. */ publicKey: string; } /** @internal */ export type HDKeySource = { seed: Uint8Array; } | { xpriv: string; }; /** Optional restore data when deserializing an HD wallet. */ export interface HDWalletRestoreData { derivationIndex?: DerivationIndexEntry[]; masterPublicKey?: string; } /** * Base class for HD wallets. Derive unlimited child keys from a single secret. * * Common derivation paths are pre-computed and cached automatically. * * @typeParam T - The secret type (e.g. {@link Phrase}, {@link Seed}, {@link Xpriv}). * * @example * ```ts * const key = await wallet.derive("m/44'/60'/0'/0/0"); * const pubKey = await wallet.derivePublicKey("m/44'/0'/0'/0/0"); * ``` */ export declare abstract class HDWallet extends SigningWallet { private _publicKey; private readonly _derivationIndex; /** @internal */ constructor(secret: T, restoreData?: HDWalletRestoreData); private createMasterKey; /** @internal */ protected abstract getKeySource(): HDKeySource; /** The master public key as a hex string. */ get publicKey(): string; /** All derivation paths that have been used, with their cached public keys. */ get derivationIndex(): DerivationIndexEntry[]; /** * Derives only the public key at a given path. Returns cached results when available. * * @param derivationPath - e.g. `"m/44'/60'/0'/0/0"`. */ derivePublicKey(derivationPath: string): Promise; /** * Derives a full key pair (public + private) at a given path. * * @param derivationPath - e.g. `"m/44'/60'/0'/0/0"`. */ derive(derivationPath: string): Promise; /** @inheritdoc */ serialize(options?: SerializeOptions): Promise; }