UNPKG

libnexa-ts

Version:

A pure and powerful Nexa SDK library.

125 lines 4.6 kB
import { HDPrivateKeyDto, HDPrivateKeyMinimalDto, IHDPrivateKey } from '../common/interfaces'; import { Networkish } from '../common/types'; import { default as PrivateKey } from './privatekey'; import { default as PublicKey } from './publickey'; import { Network } from '../core/network/network'; import { default as HDPublicKey } from './hdpublickey'; export default class HDPrivateKey implements IHDPrivateKey { private static readonly MINIMUM_ENTROPY_BITS; private static readonly BITS_TO_BYTES; private static readonly MAXIMUM_ENTROPY_BITS; private static readonly PrivateKeySize; private static readonly PrivateKeyStart; private static readonly PrivateKeyEnd; private static readonly ChecksumStart; private static readonly ChecksumEnd; private _hdPublicKey?; readonly privateKey: PrivateKey; readonly publicKey: PublicKey; readonly network: Network; readonly depth: number; readonly parentFingerPrint: Uint8Array; readonly fingerPrint: Uint8Array; readonly chainCode: Uint8Array; readonly childIndex: number; readonly checksum: Uint8Array; readonly xprivkey: string; /** * Represents an instance of an hierarchically derived private key. * * More info on https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki */ constructor(arg?: string | Uint8Array | IHDPrivateKey | HDPrivateKeyDto | HDPrivateKeyMinimalDto | Networkish); private static _classifyArgument; get hdPublicKey(): HDPublicKey; get xpubkey(): string; private static _isDtoObject; private static _isMinimalDtoObject; private static _isIHDPrivKey; /** * Verifies that a given path is valid. * * @param arg * @param hardened */ static isValidPath(arg: string | number, hardened?: boolean): boolean; static fromString(xprivkey: string): HDPrivateKey; /** * Returns the string representation of this private key (ext privkey). */ toString(): string; /** * Build a HDPrivateKey from a buffer * * @param buf */ static fromBuffer(buf: Uint8Array): HDPrivateKey; /** * Returns a buffer representation of the HDPrivateKey */ toBuffer(): Uint8Array; toJSON: () => HDPrivateKeyDto; /** * Returns a plain object with a representation of this private key. */ toObject(): HDPrivateKeyDto; static fromObject(arg: HDPrivateKeyDto): HDPrivateKey; static fromMinimalObject(arg: HDPrivateKeyMinimalDto): HDPrivateKey; /** * Generate a private key from a seed, as described in BIP32 * * @param seed * @param network * @return HDPrivateKey */ static fromSeed(seed: string | Uint8Array, network?: Networkish): HDPrivateKey; /** * Get a derived child based on a string or number. * * If the first argument is a string, it's parsed as the full path of * derivation. Valid values for this argument include "m" (which returns the * same private key), "m/0/1/40/2'/1000", where the ' quote means a hardened * derivation. * * If the first argument is a number, the child with that index will be * derived. If the second argument is truthy, the hardened version will be * derived. See the example usage for clarification. * * @example * ```javascript * let parent = new HDPrivateKey('xprv...'); * let child_0_1_2h = parent.deriveChild(0).deriveChild(1).deriveChild(2, true); * let copy_of_child_0_1_2h = parent.deriveChild("m/0/1/2'"); * assert(child_0_1_2h.xprivkey === copy_of_child_0_1_2h.xprivkey); * ``` * * @param arg * @param hardened * @return HDPrivateKey */ deriveChild(arg: string | number, hardened?: boolean): HDPrivateKey; private _deriveWithNumber; private _deriveFromString; private static _buildFromSeed; private static _buildFromObject; private static _buildFromMinimalObject; private static _buildFromSerialized; /** * Receives a object with buffers in all the properties and populates the * internal structure */ private static _buildFromBuffers; private static _validateBufferArguments; private static _generateRandomly; /** * Will return the corresponding hd public key * * @returns An extended public key generated from the hd private key */ getHDPublicKey(): HDPublicKey; /** * Returns the console representation of this extended private key. */ inspect(): string; } //# sourceMappingURL=hdprivatekey.d.ts.map