Class Utils

Hierarchy

  • Utils

Index

Methods

Static derivePrivateKey

  • derivePrivateKey(brainKey: string, sequence: number): KeyPrivate
  • Calculate derived private key apart from primary(with sequence number 0). NOTE: May be used as additional keys when creating account - owner, memo key

    Parameters

    • brainKey: string

      Brain key string.

    • sequence: number

      Sequence number to derive private key from it. If selected 0, primary private key is generated.

    Returns KeyPrivate

    KeyPrivate object.

Static elGamalPrivate

  • elGamalPrivate(privateKeyWif: string): string
  • Generates El Gamal key for content exchange from given private key WIF string

    Parameters

    • privateKeyWif: string

      WIF formatted private key of account for which generating El Gamal key

    Returns string

    El Gamal private key string.

Static elGamalPublic

  • elGamalPublic(elGamalPrivate: string): string
  • Generates El Gamal public key from given El Gamal private key

    Parameters

    • elGamalPrivate: string

      El Gamal private key string.

    Returns string

    ElGamal public key string.

Static formatAmountForAsset

  • Formats amount to format with decimal numbers. Note: Most of amount values are already formatted for this precision format.

    Parameters

    • amount: number

      Amount of asset in DCore network format.

    • asset: DCoreAssetObject

      Asset object to format amount to.

    Returns number

    Formatted number in format with decimal numbers.

Static formatAmountForDCTAsset

  • formatAmountForDCTAsset(amount: number): number
  • Formats amount to DCT precision. Value is devided by asset's precision factor Note: Most of amount values are already formatted for this precision format.

    Parameters

    • amount: number

      Amount to be formatted.

    Returns number

    DCore formatted amount.

Static formatAmountToAsset

  • Format amount value for DCore, to format without decimal numbers.

    Parameters

    • amount: number

      Amount with decimal numbers to format.

    • asset: DCoreAssetObject

      Asset object for formatting.

    Returns number

    Formatted number.

Static formatToReadiblePrice

  • formatToReadiblePrice(dctAmount: number): string
  • Format DCT price amount from blockchain format to real and readable formatted string.

    Example: Amount price from blockchain is 1, formatted price 0.00000001 DCT

    Parameters

    • dctAmount: number

      Amount of DCT asset.

    Returns string

    Formatted amount in string format.

Static generateBrainKeyElGamalKey

Static generateElGamalKeys

  • generateElGamalKeys(privateKeyWif: string): ElGamalKeys
  • Calculate El Gamal keys pair from WIF private key

    Parameters

    • privateKeyWif: string

      WIF formatted private key of account for which generating El Gamal keys

    Returns ElGamalKeys

    ElGamalKeys object.

Static generateKeys

  • Generate private and public key from given brain key.

    Parameters

    • fromBrainKey: string

      Brain key to generate keys from.

    Returns [KeyPrivate, KeyPublic]

    [privateKey: KeyPrivate, publicKey: KeyPublic] Keys.

Static generateNonce

  • generateNonce(): string

Static getBrainKeyInfo

Static getPublicKey

  • getPublicKey(privateKey: string): KeyPublic
  • Calculate public key from given private key.

    Parameters

    • privateKey: string

      Private key to get public key for.

    Returns KeyPublic

    KeyPublic object.

Static normalize

  • normalize(brainKey: string): string
  • Normalize brain key for further usage in Utils's methods

    Parameters

    • brainKey: string

      Brain key generated from Utils.suggestBrainKey or from wallet CLI

    Returns string

    Normalized brain key

Static privateKeyFromWif

  • Create KeyPrivate object from WIF format of private key.

    Parameters

    • pkWif: string

      Private key in WIF(hex) (Wallet Import Format) format.

    Returns KeyPrivate

    KeyPrivate object.

Static publicKeyFromString

  • publicKeyFromString(pubKeyString: string): KeyPublic
  • Create KeyPublic object from string format of public key.

    Parameters

    • pubKeyString: string

      Public key string.

    Returns KeyPublic

    KeyPublic object.

Static ripemdHash

  • ripemdHash(fromBuffer: string): string
  • RIPEMD 160 hash

    Parameters

    • fromBuffer: string

      Buffer to calculate hash from.

    Returns string

    RIPEMD160 hash.

Static suggestBrainKey

  • suggestBrainKey(): string

Powered by DECENT