address

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 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"
)

Variables

View Source
var (
	StakingProtocolAddrHash     = hash160b([]byte("staking"))
	RewardingProtocolAddrHash   = hash160b([]byte("rewarding"))
	StakingCreateAddrHash       = bytesToHash160([]byte("stakingCreate"))
	StakingAddDepositAddrHash   = bytesToHash160([]byte("stakingAddDeposit"))
	StakingChangeCandAddrHash   = bytesToHash160([]byte("stakingChangeCand"))
	StakingUnstakeAddrHash      = bytesToHash160([]byte("stakingUnstake"))
	StakingWithdrawAddrHash     = bytesToHash160([]byte("stakingWithdraw"))
	StakingRestakeAddrHash      = bytesToHash160([]byte("stakingRestake"))
	StakingTransferAddrHash     = bytesToHash160([]byte("stakingTransfer"))
	StakingRegisterCandAddrHash = bytesToHash160([]byte("stakingRegisterCand"))
	StakingUpdateCandAddrHash   = bytesToHash160([]byte("stakingUpdateCand"))
)

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

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 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

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