UNPKG

libnexa-ts

Version:

A pure and powerful Nexa SDK library.

115 lines 4.2 kB
import { HDPublicKeyDto, HDPublicKeyMinimalDto, IHDPrivateKey, IHDPublicKey } from '../common/interfaces'; import { Network } from '../core/network/network'; import { default as PublicKey } from './publickey'; import { AddressType } from '../core/address/address-formatter'; import { default as Address } from '../core/address/address'; export default class HDPublicKey implements IHDPublicKey { private static readonly PublicKeySize; private static readonly PublicKeyStart; private static readonly PublicKeyEnd; private static readonly ChecksumStart; private static readonly ChecksumEnd; 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 xpubkey: string; /** * The representation of an hierarchically derived public key. * * See https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki * * @param arg */ constructor(arg: string | Uint8Array | HDPublicKeyDto | HDPublicKeyMinimalDto | IHDPublicKey | IHDPrivateKey); private static _classifyArgument; private static _isDtoObject; private static _isMinimalDtoObject; private static _isIHDPubKey; private static _isIHDPrivKey; /** * Verifies that a given path is valid. * * @param arg * @return {boolean} */ static isValidPath(arg: string | number): boolean; /** * Create a HDPublicKey from a buffer argument * * @param buf */ static fromBuffer(buf: Uint8Array): HDPublicKey; /** * Return a buffer representation of the xpubkey */ toBuffer(): Uint8Array; static fromString(xpubkey: string): HDPublicKey; /** * Returns the base58 checked representation of the public key * @return a string starting with "xpub..." in livenet */ toString(): string; /** * Returns the console representation of this extended public key. */ inspect(): string; static fromObject(arg: HDPublicKeyDto): HDPublicKey; static fromMinimalObject(arg: HDPublicKeyMinimalDto): HDPublicKey; toJSON: () => HDPublicKeyDto; /** * Returns a plain JavaScript object with information to reconstruct a key. */ toObject(): HDPublicKeyDto; /** * Will return an address for the hdpubkey with its defined network * * @param type - optional parameter specifying the desired type of the address. * default {@link AddressType.PayToScriptTemplate} * * @returns An address generated from the hd public key */ toAddress(type?: AddressType): Address; /** * Get a derivated 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 public key), "m/0/1/40/2/1000". * * Note that hardened keys can't be derived from a public extended key. * * If the first argument is a number, the child with that index will be * derived. See the example usage for clarification. * * @example * ```javascript * let parent = new HDPublicKey('xpub...'); * let child_0_1_2 = parent.deriveChild(0).deriveChild(1).deriveChild(2); * let copy_of_child_0_1_2 = parent.deriveChild("m/0/1/2"); * assert(child_0_1_2.xpubkey === copy_of_child_0_1_2.xpubkey); * ``` * * @param {string|number} arg */ deriveChild(arg: string | number, hardened?: boolean): HDPublicKey; private _deriveWithNumber; private _deriveFromString; private static _buildFromObject; private static _buildFromMinimalObject; private static _buildFromHDPrivateKey; private static _buildFromSerialized; /** * Receives a object with buffers in all the properties and populates the * internal structure * * @param arg */ private static _buildFromBuffers; private static _validateBufferArguments; } //# sourceMappingURL=hdpublickey.d.ts.map