address

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 146

Documentation

Index

Constants

View Source
const (
	// MainnetPrefix is the prefix added to the human readable address of mainnet
	MainnetPrefix = "io"
	// TestnetPrefix is the prefix added to the human readable address of testnet
	TestnetPrefix = "it"
)
View Source
const (
	// ZeroAddress is the IoTeX address whose hash160 is all zero
	ZeroAddress = "io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqd39ym7"

	// StakingBucketPoolAddr is the staking bucket pool address
	StakingBucketPoolAddr = "io000000000000000000000000stakingprotocol"

	// RewardingPoolAddr is the rewarding pool address
	RewardingPoolAddr = "io0000000000000000000000rewardingprotocol"

	// StakingProtocolAddr is the staking protocol address
	StakingProtocolAddr = "io1qnpz47hx5q6r3w876axtrn6yz95d70cjl35r53"

	// RewardingProtocol is the rewarding protocol address
	RewardingProtocol = "io154mvzs09vkgn0hw6gg3ayzw5w39jzp47f8py9v"
)
View Source
const V1AddressStringLength = 41

V1AddressStringLength is the length of v1 address string

Variables

View Source
var (
	StakingProtocolAddrHash   = hash160b([]byte("staking"))
	RewardingProtocolAddrHash = hash160b([]byte("rewarding"))
)

20-byte protocol address hash

View Source
var ErrInvalidAddr = errors.New("invalid address")

ErrInvalidAddr indicates the invalid address error

Functions

func Equal

func Equal(addr1 Address, addr2 Address) bool

Equal determine if two addresses are equal

func IsAddrV1Special added in v0.2.6

func IsAddrV1Special(s string) bool

IsAddrV1Special returns true for special address

Types

type AddrV1

type AddrV1 struct {
	// contains filtered or unexported fields
}

AddrV1 is V1 address format to be used on IoTeX blockchain and subchains It is composed of a 20-byte hash derived from the the public key

func (*AddrV1) Bytes

func (addr *AddrV1) Bytes() []byte

Bytes converts an address struct into a byte array

func (*AddrV1) Hex added in v0.2.4

func (addr *AddrV1) Hex() string

Hex is the hex-encoding of Bytes, prefixed with "0x"

func (*AddrV1) String

func (addr *AddrV1) String() string

String encodes an address struct into a a String encoded address string The encoded address string will start with "io" for mainnet, and with "it" for testnet

type AddrV1Special added in v0.2.6

type AddrV1Special struct {
	// contains filtered or unexported fields
}

AddrV1Special is address that consists of special text it is NOT a valid bech32 encoding of the 20-bytes hash

func (*AddrV1Special) Bytes added in v0.2.6

func (addr *AddrV1Special) Bytes() []byte

Bytes panics since it is NOT a valid bech32 encoding

func (*AddrV1Special) Hex added in v0.2.6

func (addr *AddrV1Special) Hex() string

Hex panics since it is NOT a valid bech32 encoding

func (*AddrV1Special) String added in v0.2.6

func (addr *AddrV1Special) String() string

String returns the special-text address

type Address

type Address interface {
	// String encodes the address into a string using bech32 encoding
	String() string

	// Bytes returns the underlying 20-byte public key hash
	Bytes() []byte

	// Hex is the hex-encoding of Bytes, prefixed with "0x"
	Hex() string
}

Address defines the interface of the blockchain address

func FromBytes

func FromBytes(bytes []byte) (Address, error)

FromBytes converts a byte array into an address struct

func FromHex added in v0.2.4

func FromHex(s string) (Address, error)

FromHex converts a hex-encoded string into an address struct

func FromString

func FromString(encodedAddr string) (Address, error)

FromString decodes an encoded address string into an address struct

func FromStringLegacy added in v0.2.8

func FromStringLegacy(encodedAddr string) (Address, error)

FromStringLegacy decodes an encoded address string into an address struct

type Hash160 added in v0.2.3

type Hash160 [20]byte

Hash160 for 160-bit hash used for account and smart contract address

Directories

Path Synopsis
Package bech32 includes a Bech32 string which is at most 90 characters long and consists of: The human-readable part, which is intended to convey the type of data, or anything else that is relevant to the reader.
Package bech32 includes a Bech32 string which is at most 90 characters long and consists of: The human-readable part, which is intended to convey the type of data, or anything else that is relevant to the reader.

Jump to

Keyboard shortcuts

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