account

package
v0.34.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: MPL-2.0 Imports: 16 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAddressToAccountMappingFailure = errors.New("cannot retrieve a valid account for a given address")
	ErrAccountToKeyMappingFailure     = errors.New("cannot retrieve a valid key for a given account")
	ErrNoAccountSelected              = errors.New("no account has been selected, please login")
	ErrInvalidMasterKeyCreated        = errors.New("can not create master extended key")
	ErrOnboardingNotStarted           = errors.New("onboarding must be started before choosing an account")
	ErrOnboardingAccountNotFound      = errors.New("cannot find onboarding account with the given id")
	ErrAccountKeyStoreMissing         = errors.New("account key store is not set")
)

errors

View Source
var (
	ErrInvalidAccountAddressOrKey  = errors.New("cannot parse address or key to valid account address")
	ErrInvalidMnemonicPhraseLength = errors.New("invalid mnemonic phrase length; valid lengths are 12, 15, 18, 21, and 24")
)

errors

Functions

func CreateAddress added in v0.35.0

func CreateAddress() (address, pubKey, privKey string, err error)

func FromAddress

func FromAddress(accountAddress string) common.Address

FromAddress converts account address from string to common.Address. The function is useful to format "From" field of send transaction struct.

func ParseAccountString

func ParseAccountString(account string) (accounts.Account, error)

ParseAccountString parses hex encoded string and returns is as accounts.Account.

func ToAddress

func ToAddress(accountAddress string) *common.Address

ToAddress converts account address from string to *common.Address. The function is useful to format "To" field of send transaction struct.

Types

type ErrZeroAddress added in v0.35.0

type ErrZeroAddress struct {
	// contains filtered or unexported fields
}

func (*ErrZeroAddress) Error added in v0.35.0

func (e *ErrZeroAddress) Error() string

type Info added in v0.35.0

type Info struct {
	WalletAddress string
	WalletPubKey  string
	ChatAddress   string
	ChatPubKey    string
}

Info contains wallet and chat addresses and public keys of an account.

type LoginParams added in v0.35.0

type LoginParams struct {
	ChatAddress    common.Address   `json:"chatAddress"`
	Password       string           `json:"password"`
	MainAccount    common.Address   `json:"mainAccount"`
	WatchAddresses []common.Address `json:"watchAddresses"`
}

func ParseLoginParams added in v0.35.0

func ParseLoginParams(paramsJSON string) (LoginParams, error)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager represents account manager interface.

func NewManager

func NewManager() *Manager

NewManager returns new node account manager.

func (*Manager) Accounts

func (m *Manager) Accounts() ([]gethcommon.Address, error)

Accounts returns list of addresses for selected account, including subaccounts.

func (*Manager) AccountsGenerator added in v0.35.0

func (m *Manager) AccountsGenerator() *generator.Generator

AccountsGenerator returns accountsGenerator.

func (*Manager) AddressToDecryptedAccount

func (m *Manager) AddressToDecryptedAccount(address, password string) (accounts.Account, *keystore.Key, error)

AddressToDecryptedAccount tries to load decrypted key for a given account. The running node, has a keystore directory which is loaded on start. Key file for a given address is expected to be in that directory prior to node start.

func (*Manager) CreateAccount

func (m *Manager) CreateAccount(password string) (Info, string, error)

CreateAccount creates an internal geth account BIP44-compatible keys are generated: CKD#1 is stored as account key, CKD#2 stored as sub-account root Public key of CKD#1 is returned, with CKD#2 securely encoded into account key file (to be used for sub-account derivations)

func (*Manager) GetKeystore added in v0.35.0

func (m *Manager) GetKeystore() *keystore.KeyStore

func (*Manager) GetManager added in v0.35.0

func (m *Manager) GetManager() *accounts.Manager

func (*Manager) ImportAccount added in v0.35.0

func (m *Manager) ImportAccount(privateKey *ecdsa.PrivateKey, password string) (common.Address, error)

ImportAccount imports the account specified with privateKey.

func (*Manager) ImportOnboardingAccount added in v0.35.0

func (m *Manager) ImportOnboardingAccount(id string, password string) (Info, string, error)

ImportOnboardingAccount imports the account specified by id and encrypts it with password.

func (*Manager) ImportSingleExtendedKey added in v0.35.0

func (m *Manager) ImportSingleExtendedKey(extKey *extkeys.ExtendedKey, password string) (address, pubKey string, err error)

func (*Manager) InitKeystore added in v0.35.0

func (m *Manager) InitKeystore(keydir string) error

InitKeystore sets key manager and key store.

func (*Manager) Logout

func (m *Manager) Logout()

Logout clears selected accounts.

func (*Manager) MainAccountAddress added in v0.35.0

func (m *Manager) MainAccountAddress() (common.Address, error)

MainAccountAddress returns currently selected watch addresses.

func (*Manager) RecoverAccount

func (m *Manager) RecoverAccount(password, mnemonic string) (Info, error)

RecoverAccount re-creates master key using given details. Once master key is re-generated, it is inserted into keystore (if not already there).

func (*Manager) RemoveOnboarding added in v0.35.0

func (m *Manager) RemoveOnboarding()

RemoveOnboarding reset the current onboarding struct setting it to nil and deleting the accounts from memory.

func (*Manager) SelectAccount

func (m *Manager) SelectAccount(loginParams LoginParams) error

SelectAccount selects current account, by verifying that address has corresponding account which can be decrypted using provided password. Once verification is done, all previous identities are removed).

func (*Manager) SelectedChatAccount added in v0.35.0

func (m *Manager) SelectedChatAccount() (*SelectedExtKey, error)

SelectedChatAccount returns currently selected chat account

func (*Manager) SetAccountAddresses added in v0.35.0

func (m *Manager) SetAccountAddresses(main common.Address, secondary ...common.Address)

func (*Manager) SetChatAccount added in v0.35.0

func (m *Manager) SetChatAccount(privKey *ecdsa.PrivateKey)

SetChatAccount initializes selectedChatAccount with privKey

func (*Manager) StartOnboarding added in v0.35.0

func (m *Manager) StartOnboarding(accountsCount, mnemonicPhraseLength int) ([]*OnboardingAccount, error)

StartOnboarding starts the onboarding process generating accountsCount accounts and returns a slice of OnboardingAccount.

func (*Manager) VerifyAccountPassword

func (m *Manager) VerifyAccountPassword(keyStoreDir, address, password string) (*keystore.Key, error)

VerifyAccountPassword tries to decrypt a given account key file, with a provided password. If no error is returned, then account is considered verified.

func (*Manager) WatchAddresses added in v0.35.0

func (m *Manager) WatchAddresses() []common.Address

WatchAddresses returns currently selected watch addresses.

type Onboarding added in v0.35.0

type Onboarding struct {
	// contains filtered or unexported fields
}

Onboarding is a struct contains a slice of OnboardingAccount.

func NewOnboarding added in v0.35.0

func NewOnboarding(n, mnemonicPhraseLength int) (*Onboarding, error)

NewOnboarding returns a new onboarding struct generating n accounts.

func (*Onboarding) Account added in v0.35.0

func (o *Onboarding) Account(id string) (*OnboardingAccount, error)

Account returns an OnboardingAccount by id.

func (*Onboarding) Accounts added in v0.35.0

func (o *Onboarding) Accounts() []*OnboardingAccount

Accounts return the list of OnboardingAccount generated.

type OnboardingAccount added in v0.35.0

type OnboardingAccount struct {
	ID string `json:"id"`

	Info Info `json:"info"`
	// contains filtered or unexported fields
}

OnboardingAccount is returned during onboarding and contains its ID and the mnemonic to re-generate the same account Info keys.

type SelectedExtKey

type SelectedExtKey struct {
	Address     common.Address
	AccountKey  *keystore.Key
	SubAccounts []accounts.Account
}

SelectedExtKey is a container for the selected (logged in) external account.

func (*SelectedExtKey) Hex

func (k *SelectedExtKey) Hex() string

Hex dumps address of a given extended key as hex string.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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