UNPKG

@bsv/sdk

Version:

BSV Blockchain Software Development Kit

131 lines 6.12 kB
import PrivateKey from '../primitives/PrivateKey.js'; import PublicKey from '../primitives/PublicKey.js'; /** * @deprecated * The HD class implements the Bitcoin Improvement Proposal 32 (BIP32) hierarchical deterministic wallets. * It allows the generation of child keys from a master key, ensuring a tree-like structure of keys and addresses. * This class is deprecated due to the introduction of BRC-42, which offers an enhanced key derivation scheme. * BRC-42 uses invoice numbers for key derivation, improving privacy and scalability compared to BIP32. * * @class HD * @deprecated Replaced by BRC-42 which uses invoice numbers and supports private derivation. */ export default class HD { versionBytesNum: number; depth: number; parentFingerPrint: number[]; childIndex: number; chainCode: number[]; privKey: PrivateKey; pubKey: PublicKey; constants: { pubKey: number; privKey: number; }; /** * Constructor for the BIP32 HD wallet. * Initializes an HD wallet with optional parameters for version bytes, depth, parent fingerprint, child index, chain code, private key, and public key. * @param versionBytesNum - Version bytes number for the wallet. * @param depth - Depth of the key in the hierarchy. * @param parentFingerPrint - Fingerprint of the parent key. * @param childIndex - Index of the child key. * @param chainCode - Chain code for key derivation. * @param privKey - Private key of the wallet. * @param pubKey - Public key of the wallet. */ constructor(versionBytesNum?: number, depth?: number, parentFingerPrint?: number[], childIndex?: number, chainCode?: number[], privKey?: PrivateKey, pubKey?: PublicKey); /** * Generates a new HD wallet with random keys. * This method creates a root HD wallet with randomly generated private and public keys. * @returns {HD} The current HD instance with generated keys. */ fromRandom(): this; /** * Generates a new HD wallet with random keys. * This method creates a root HD wallet with randomly generated private and public keys. * @returns {HD} A new HD instance with generated keys. * @static */ static fromRandom(): HD; /** * Initializes the HD wallet from a given base58 encoded string. * This method decodes a provided string to set up the HD wallet's properties. * @param str - A base58 encoded string representing the wallet. * @returns {HD} The new instance with properties set from the string. */ static fromString(str: string): HD; /** * Initializes the HD wallet from a given base58 encoded string. * This method decodes a provided string to set up the HD wallet's properties. * @param str - A base58 encoded string representing the wallet. * @returns {HD} The current instance with properties set from the string. */ fromString(str: string): this; /** * Initializes the HD wallet from a seed. * This method generates keys and other properties from a given seed, conforming to the BIP32 specification. * @param bytes - An array of bytes representing the seed. * @returns {HD} The current instance with properties set from the seed. */ static fromSeed(bytes: number[]): HD; /** * Initializes the HD wallet from a seed. * This method generates keys and other properties from a given seed, conforming to the BIP32 specification. * @param bytes - An array of bytes representing the seed. * @returns {HD} The current instance with properties set from the seed. */ fromSeed(bytes: number[]): this; /** * Initializes the HD wallet from a binary buffer. * Parses a binary buffer to set up the wallet's properties. * @param buf - A buffer containing the wallet data. * @returns {HD} The new instance with properties set from the buffer. */ static fromBinary(buf: number[]): HD; /** * Initializes the HD wallet from a binary buffer. * Parses a binary buffer to set up the wallet's properties. * @param buf - A buffer containing the wallet data. * @returns {HD} The current instance with properties set from the buffer. */ fromBinary(buf: number[]): this; /** * Converts the HD wallet to a base58 encoded string. * This method provides a string representation of the HD wallet's current state. * @returns {string} A base58 encoded string of the HD wallet. */ toString(): string; /** * Derives a child HD wallet based on a given path. * The path specifies the hierarchy of the child key to be derived. * @param path - A string representing the derivation path (e.g., 'm/0'/1). * @returns {HD} A new HD instance representing the derived child wallet. */ derive(path: string): HD; /** * Derives a child HD wallet from the current wallet based on an index. * This method generates either a private or public child key depending on the current wallet's state. * @param i - The index of the child key to derive. * @returns {HD} A new HD instance representing the derived child wallet. */ deriveChild(i: number): HD; /** * Converts the current HD wallet to a public-only wallet. * This method strips away the private key information, leaving only the public part. * @returns {HD} A new HD instance representing the public-only wallet. */ toPublic(): HD; /** * Converts the HD wallet into a binary representation. * This method serializes the wallet's properties into a binary format. * @returns {number[]} An array of numbers representing the binary data of the wallet. */ toBinary(): number[]; /** * Checks if the HD wallet contains a private key. * This method determines whether the wallet is a private key wallet or a public key only wallet. * @returns {boolean} A boolean value indicating whether the wallet has a private key (true) or not (false). */ isPrivate(): boolean; } //# sourceMappingURL=HD.d.ts.map