chaingate
Version:
Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO
64 lines (63 loc) • 2.25 kB
TypeScript
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<T extends Secret> extends SigningWallet<T> {
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<DerivedPublicKey>;
/**
* 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<DerivedKey>;
/** @inheritdoc */
serialize(options?: SerializeOptions): Promise<WalletSerialized>;
}