Documentation ¶
Overview ¶
Package chainhash defines the hash functions used.
This package provides a wrapper around the hash function used. This is designed to isolate the code that needs to be changed to support coins with different hash functions (i.e, bitcoin vs decred).
Index ¶
Constants ¶
const HashBlockSize = blake256.BlockSize
const HashSize = 32
Size of array used to store sha hashes. See Hash.
const MaxHashStringSize = HashSize * 2
MaxHashStringSize is the maximum length of a Hash hash string.
Variables ¶
var ErrHashStrSize = fmt.Errorf("max hash string length is %v bytes", MaxHashStringSize)
ErrHashStrSize describes an error that indicates the caller specified a hash string that has too many characters.
Functions ¶
Types ¶
type Hash ¶
Hash is used in several of the bitcoin messages and common structures. It typically represents the double sha256 of data.
func NewHash ¶
NewHash returns a new Hash from a byte slice. An error is returned if the number of bytes passed in is not HashSize.
func NewHashFromStr ¶
NewHashFromStr creates a Hash from a hash string. The string should be the hexadecimal string of a byte-reversed hash, but any missing characters result in zero padding at the end of the Hash.
func (*Hash) Bytes ¶
Bytes returns the bytes which represent the hash as a byte slice.
NOTE: This makes a copy of the bytes and should have probably been named CloneBytes. It is generally cheaper to just slice the hash directly thereby reusing the same bytes rather than calling this method.