multivacaddress

package
v0.0.0-...-4f0ab6e Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 7 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultAddrShard

func GetDefaultAddrShard(mtvAddr string) int

GetDefaultAddrShard returns the default shard of address.

Types

type Address

type Address []byte

Address defines the data structure of multivac address.

func GenerateAddress

func GenerateAddress(pk signature.PublicKey, addrType AddressType) Address

GenerateAddress generates the MTV address based on the public key and address type

func GenerateAddressByPublicKeyHash

func GenerateAddressByPublicKeyHash(pubKey PublicKeyHash, addrType AddressType) Address

GenerateAddressByPublicKeyHash accept after sha256 and ripemd hash length of 20 byte array, and the address type as a parameter to generate the MTV address.

func StringToUserAddress

func StringToUserAddress(str string) (Address, error)

StringToUserAddress converts pk string to multivac user address

func (Address) GetPublicKeyHash

func (addr Address) GetPublicKeyHash(addrType AddressType) (*PublicKeyHash, error)

GetPublicKeyHash returns the hash array of public key.

func (Address) IsEqual

func (addr Address) IsEqual(target Address) bool

IsEqual returns true if target is the same as hash.

func (Address) String

func (addr Address) String() string

func (Address) VerifyAddressType

func (addr Address) VerifyAddressType(addrType AddressType) error

VerifyAddressType determines whether it is legal by address type. This method only verifies that the address is formatted correctly.

func (Address) VerifyPublicKey

func (addr Address) VerifyPublicKey(pk signature.PublicKey, addrType AddressType) error

VerifyPublicKey verifies that the address format is valid before verifying that the address and public key match

type AddressType

type AddressType byte

AddressType define the multivac address type.

const (
	// UserAddress defines the address type for user.Base58Check encoding, it is prefixed with 1
	UserAddress AddressType = 0x00
	// SystemContractAddress defines the address type for system contract address.
	SystemContractAddress AddressType = 0x01
	// SmartContractAddress defines the address type for smart contract address.
	// Base58Check encoding, it is prefixed with 3.
	SmartContractAddress AddressType = 0x05
)

type PublicKeyHash

type PublicKeyHash [publicKeyHashSize]byte

PublicKeyHash is an array used to store the hasn of public key.

Jump to

Keyboard shortcuts

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