types

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 4 Imported by: 51

Documentation

Index

Constants

View Source
const (
	HashLength    = 32
	AddressLength = 20
)

Lengths of hashes and addresses in bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address [AddressLength]byte

func Bytes2Address

func Bytes2Address(b []byte) Address

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

func String2Address

func String2Address(s string) Address

func (Address) Bytes

func (a Address) Bytes() []byte

func (Address) Hex

func (a Address) Hex() string

Hex returns an EIP55-compliant hex string representation of the address.

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

Serialize given address to JSON

func (*Address) MarshalTo

func (a *Address) MarshalTo(data []byte) (int, error)

func (*Address) Set

func (a *Address) Set(other Address)

Sets a to other

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.

func (Address) ShortString

func (a Address) ShortString() string

func (Address) Size

func (a Address) Size() int

func (Address) String

func (a Address) String() string

func (*Address) Unmarshal

func (a *Address) Unmarshal(data []byte) error

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(data []byte) error

UnmarshalJSON parses a hash in hex syntax.

type Hash

type Hash [HashLength]byte

func Bytes2Hash

func Bytes2Hash(b []byte) Hash

func String2Hash

func String2Hash(s string) Hash

func (Hash) Bytes

func (h Hash) Bytes() []byte

func (Hash) Hex

func (h Hash) Hex() string

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

Serialize given address to JSON

func (*Hash) MarshalTo

func (h *Hash) MarshalTo(data []byte) (int, error)

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

func (Hash) ShortString

func (h Hash) ShortString() string

func (Hash) Size

func (h Hash) Size() int

func (Hash) String

func (h Hash) String() string

func (*Hash) Unmarshal

func (h *Hash) Unmarshal(data []byte) error

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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