util

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2019 License: GPL-3.0, Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	HashLength    = 32
	AddressLength = 20
)

Lengths of hashes and addresses in bytes.

Variables

This section is empty.

Functions

func AddressToBig

func AddressToBig(addr types.Address) *big.Int

Big converts an address to a big integer.

func AddressToBytes added in v1.0.0

func AddressToBytes(addr types.Address) []byte

AddressToBytes convert address to []byte

func BigToAddress

func BigToAddress(b *big.Int) types.Address

BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.

func BigToHash

func BigToHash(b *big.Int) types.Hash

BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.

func Bytes2Hex added in v1.0.0

func Bytes2Hex(d []byte) string

Bytes2Hex returns the hexadecimal encoding of d.

func BytesToAddress

func BytesToAddress(b []byte) types.Address

BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.

func BytesToHash

func BytesToHash(b []byte) types.Hash

BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.

func Encode

func Encode(b []byte) string

Encode encodes b as a hex string with 0x prefix.

func FromHex

func FromHex(s string) []byte

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".

func HashToBig

func HashToBig(hash types.Hash) *big.Int

HashToBig converts a hash to a big integer.

func HashToBytes

func HashToBytes(hash types.Hash) []byte

HashToBytes convert hash to []byte

func Hex2Bytes

func Hex2Bytes(str string) []byte

Hex2Bytes returns the bytes represented by the hexadecimal string str.

func HexToAddress

func HexToAddress(s string) types.Address

HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.

func HexToHash

func HexToHash(s string) types.Hash

HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL