Documentation ¶
Index ¶
- Constants
- func Compose(typ string, subAddresses []Addressable) ([]byte, error)
- func Derive(address, key []byte) []byte
- func Hash(typ string, key []byte) []byte
- func LengthPrefix(bz []byte) ([]byte, error)
- func Module(moduleName string, derivationKeys ...[]byte) []byte
- func MustLengthPrefix(bz []byte) []byte
- type Addressable
Constants ¶
const Len = sha256.Size
Len is the length of base addresses
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 ¶
Derive derives a new address from the main `address` and a derivation `key`. This function is used to create a sub accounts. To create a module accounts use the `Module` function.
func Hash ¶
Hash creates a new address from address type and key. The functions should only be used by new types defining their own address function (eg public keys).
func LengthPrefix ¶
LengthPrefix prefixes the address bytes with its length, this is used for example for variable-length components in store keys.
func Module ¶
Module is a specialized version of a composed address for modules. Each module account is constructed from a module name and a sequence of derivation keys (at least one derivation key must be provided). The derivation keys must be unique in the module scope, and is usually constructed from some object id. Example, let's a x/dao module, and a new DAO object, it's address would be:
address.Module(dao.ModuleName, newDAO.ID)
func MustLengthPrefix ¶
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.