Utility functions for Bitcoin hashes and targets
npm install bitcoin-util
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).
Converts the difficulty target
targetto its compact representation (used in the "bits" field in block headers).
targetshould be a
Buffer(little-endian, the zeroes should be at the end). Returns a
Converts the compressed target integer
bitsto its target hash representation. Returns a