bitcoin-util

2.0.3 • Public • Published

bitcoin-util

npm version Build Status Dependency Status

Utility functions for Bitcoin hashes and targets

Usage

npm install bitcoin-util

Methods

toHash(hex)

Takes a hex string that contains a Bitcoin hash as input, and returns a Bitcoin-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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.3
    1,357
    • latest

Version History

Package Sidebar

Install

npm i bitcoin-util

Weekly Downloads

1,357

Version

2.0.3

License

MIT

Last publish

Collaborators

  • mappum