Documentation ¶
Index ¶
- Variables
- type AccountManager
- func (m *AccountManager) Contains(encodedAddr string) (bool, error)
- func (m *AccountManager) Import(keyBytes []byte) error
- func (m *AccountManager) NewAccount() (keypair.PrivateKey, error)
- func (m *AccountManager) Remove(encodedAddr string) error
- func (m *AccountManager) SignAction(encodedAddr string, elp action.Envelope) (action.SealedEnvelope, error)
- func (m *AccountManager) SignHash(encodedAddr string, hash []byte) ([]byte, error)
- 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(encodedAddr 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() (keypair.PrivateKey, error)
NewAccount creates and stores a new account
func (*AccountManager) Remove ¶
func (m *AccountManager) Remove(encodedAddr string) error
Remove removes the given account if exists
func (*AccountManager) SignAction ¶
func (m *AccountManager) SignAction(encodedAddr string, elp action.Envelope) (action.SealedEnvelope, error)
SignAction signs an action envelope.
type KeyStore ¶
type KeyStore interface { Has(string) (bool, error) Get(string) (keypair.PrivateKey, error) Store(string, keypair.PrivateKey) 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) SignAction ¶
func (m *SingleAccountManager) SignAction(elp action.Envelope) (action.SealedEnvelope, error)
SignAction signs an action envelope.