terracoin-util

2.0.3 • Public • Published

terracoin-util

npm version Build Status Dependency Status

Utility functions for Terracoin hashes and targets

Usage

npm install terracoin-util

Methods

toHash(hex)

Takes a hex string that contains a Terracoin hash as input, and returns a Terracoin-protocol-friendly little-endian Buffer. Throws an error if the hex string is not of length 64 (representing a 256-bit hash).

compressTarget(target)

Converts the difficulty target target to its compact representation (used in the "bits" field in block headers). target should be a Buffer (little-endian, the zeroes should be at the end). Returns a number.

expandTarget(bits)

Converts the compressed target integer bits to its target hash representation. Returns a Buffer.

/terracoin-util/

    Package Sidebar

    Install

    npm i terracoin-util

    Weekly Downloads

    2

    Version

    2.0.3

    License

    MIT

    Unpacked Size

    8.24 kB

    Total Files

    9

    Last publish

    Collaborators

    • thesin