Documentation
¶
Index ¶
- Variables
- type AccountManager
- func (m *AccountManager) Contains(rawAddr string) (bool, error)
- func (m *AccountManager) Import(keyBytes []byte) error
- func (m *AccountManager) NewAccount() (*iotxaddress.Address, error)
- func (m *AccountManager) Remove(rawAddr string) error
- func (m *AccountManager) SignHash(rawAddr string, hash []byte) ([]byte, error)
- func (m *AccountManager) SignTransfer(rawAddr string, rawTransfer *action.Transfer) (*action.Transfer, error)
- func (m *AccountManager) SignVote(rawAddr string, rawVote *action.Vote) (*action.Vote, error)
- type Key
- type KeyStore
- type SingleAccountManager
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTransfer indicates the error of transfer ErrTransfer = errors.New("transfer error") // ErrVote indicates the error of vote ErrVote = errors.New("vote error") )
var ( // ErrKey indicates the error of key ErrKey = errors.New("key error") // ErrExist is the error that the key already exists in map ErrExist = errors.New("key already exists") // ErrNotExist is the error that the key does not exist in map ErrNotExist = errors.New("key does not exist") )
var ( // ErrNilAccountManager indicates that account manager is nil ErrNilAccountManager = errors.New("account manager is nil") // ErrNumAccounts indicates invalid number of accounts in keystore ErrNumAccounts = errors.New("number of accounts is invalid") )
Functions ¶
This section is empty.
Types ¶
type AccountManager ¶
type AccountManager struct {
// contains filtered or unexported fields
}
AccountManager manages keystore based accounts
func NewMemAccountManager ¶
func NewMemAccountManager() *AccountManager
NewMemAccountManager creates a new account manager based on in-memory keystore
func NewPlainAccountManager ¶
func NewPlainAccountManager(dir string) (*AccountManager, error)
NewPlainAccountManager creates a new account manager based on plain keystore
func (*AccountManager) Contains ¶
func (m *AccountManager) Contains(rawAddr string) (bool, error)
Contains returns whether keystore contains the given account
func (*AccountManager) Import ¶
func (m *AccountManager) Import(keyBytes []byte) error
Import imports key bytes and stores it as a new account
func (*AccountManager) NewAccount ¶
func (m *AccountManager) NewAccount() (*iotxaddress.Address, error)
NewAccount creates a new account
func (*AccountManager) Remove ¶
func (m *AccountManager) Remove(rawAddr string) error
Remove removes the given account if exists
func (*AccountManager) SignHash ¶
func (m *AccountManager) SignHash(rawAddr string, hash []byte) ([]byte, error)
SignHash signs a hash
func (*AccountManager) SignTransfer ¶
func (m *AccountManager) SignTransfer(rawAddr string, rawTransfer *action.Transfer) (*action.Transfer, error)
SignTransfer signs a transfer
type KeyStore ¶
type KeyStore interface { Has(string) (bool, error) Get(string) (*iotxaddress.Address, error) Store(string, *iotxaddress.Address) error Remove(string) error All() ([]string, error) }
KeyStore defines an interface that supports operations on keystore object
func NewMemKeyStore ¶
func NewMemKeyStore() KeyStore
NewMemKeyStore creates a new instance of MemKeyStore
func NewPlainKeyStore ¶
NewPlainKeyStore returns a new instance of plain keystore
type SingleAccountManager ¶
type SingleAccountManager struct {
// contains filtered or unexported fields
}
SingleAccountManager is a special account manager that maintains a single account in keystore
func NewSingleAccountManager ¶
func NewSingleAccountManager(accountManager *AccountManager) (*SingleAccountManager, error)
NewSingleAccountManager creates a new single account manager
func (*SingleAccountManager) SignHash ¶
func (m *SingleAccountManager) SignHash(hash []byte) ([]byte, error)
SignHash signs a hash
func (*SingleAccountManager) SignTransfer ¶
SignTransfer signs a transfer