keystore

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTransfer indicates the error of transfer
	ErrTransfer = errors.New("transfer error")
	// ErrVote indicates the error of vote
	ErrVote = errors.New("vote error")
)
View Source
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")
)
View Source
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

func (*AccountManager) SignVote

func (m *AccountManager) SignVote(rawAddr string, rawVote *action.Vote) (*action.Vote, error)

SignVote signs a vote

type Key

type Key struct {
	PublicKey  string
	PrivateKey string
	RawAddress string
}

Key defines the struct to be stored in keystore object

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

func NewPlainKeyStore(dir string) (KeyStore, error)

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

func (m *SingleAccountManager) SignTransfer(rawTransfer *action.Transfer) (*action.Transfer, error)

SignTransfer signs a transfer

func (*SingleAccountManager) SignVote

func (m *SingleAccountManager) SignVote(rawVote *action.Vote) (*action.Vote, error)

SignVote signs a vote

Jump to

Keyboard shortcuts

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