address

package
v0.46.13 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 6 Imported by: 1,118

README

Account

This package defines Cosmos SDK address-related functions.

References

Documentation

Index

Constants

View Source
const Len = sha256.Size

Len is the length of base addresses

View Source
const MaxAddrLen = 255

MaxAddrLen is the maximum allowed length (in bytes) for an address.

Variables

This section is empty.

Functions

func Compose

func Compose(typ string, subAddresses []Addressable) ([]byte, error)

Compose creates a new address based on sub addresses.

func Derive

func Derive(address []byte, key []byte) []byte

Derive derives a new address from the main `address` and a derivation `key`.

func Hash

func Hash(typ string, key []byte) []byte

Hash creates a new address from address type and key

func LengthPrefix

func LengthPrefix(bz []byte) ([]byte, error)

LengthPrefix prefixes the address bytes with its length, this is used for example for variable-length components in store keys.

func Module

func Module(moduleName string, key []byte) []byte

Module is a specialized version of a composed address for modules. Each module account is constructed from a module name and module account key.

func MustLengthPrefix

func MustLengthPrefix(bz []byte) []byte

MustLengthPrefix is LengthPrefix with panic on error.

Types

type Addressable

type Addressable interface {
	Address() []byte
}

Addressable represents any type from which we can derive an address.

type Codec added in v0.46.0

type Codec interface {
	// StringToBytes decodes text to bytes
	StringToBytes(text string) ([]byte, error)
	// BytesToString encodes bytes to text
	BytesToString(bz []byte) (string, error)
}

Codec defines an interface to convert addresses from and to string/bytes.

Jump to

Keyboard shortcuts

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