UNPKG

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

46 lines (45 loc) 1.67 kB
import { Secret } from '../Secret'; import { Wallet } from '../Wallet'; import type { WalletSerialized, SecretWalletType } from '../WalletSerialized'; /** * Options for {@link SigningWallet.serialize}. */ export interface SerializeOptions { /** * Set to `true` to suppress the console warning about serializing unencrypted private keys. * @default false */ acknowledge?: boolean; } /** * Base class for wallets that hold private key material. Supports encryption. * * @typeParam T - The secret type this wallet holds. */ export declare abstract class SigningWallet<T extends Secret> extends Wallet { abstract readonly walletType: SecretWalletType; /** @internal */ protected readonly secret: T; /** @internal */ constructor(secret: T); /** Whether the wallet's secret material is currently encrypted. */ get encrypted(): boolean; /** * Encrypts the wallet with a password. After encryption, operations that * need the secret will prompt for the password automatically. * * @param password - The encryption password. * @param askForPassword - Callback for future password prompts. * @throws {@link AlreadyEncryptedError} if already encrypted. */ encrypt(password: string, askForPassword: () => Promise<string | null>): Promise<void>; /** @internal */ protected abstract doSerialize(): WalletSerialized; /** * Serializes the wallet for storage. Warns if serializing unencrypted * unless `options.acknowledge` is `true`. * * @param options - Serialization options. */ serialize(options?: SerializeOptions): Promise<WalletSerialized>; }