account

package
v0.110.3 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MPL-2.0 Imports: 21 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) types.Address

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

func ParseAccountString

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

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

func ToAddress

func ToAddress(accountAddress string) *types.Address

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

Types

type ErrCannotLocateKeyFile added in v0.102.6

type ErrCannotLocateKeyFile struct {
	Msg string
}

func (ErrCannotLocateKeyFile) Error added in v0.102.6

func (e ErrCannotLocateKeyFile) Error() string

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 GethManager added in v0.39.0

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

GethManager represents account manager interface.

func NewGethManager added in v0.39.7

func NewGethManager() *GethManager

NewGethManager returns new node account manager.

func (*GethManager) GetManager added in v0.39.0

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

func (*GethManager) InitKeystore added in v0.39.0

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

InitKeystore sets key manager and key store.

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    types.Address          `json:"chatAddress"`
	Password       string                 `json:"password"`
	MainAccount    types.Address          `json:"mainAccount"`
	WatchAddresses []types.Address        `json:"watchAddresses"`
	MultiAccount   *multiaccounts.Account `json:"multiAccount"`
}

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 (*Manager) Accounts

func (m *Manager) Accounts() ([]types.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) (types.Account, *types.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) (generator.GeneratedAccountInfo, 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) DeleteAccount added in v0.100.0

func (m *Manager) DeleteAccount(keyDirPath string, address types.Address) error

func (*Manager) GetKeystore added in v0.35.0

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

GetKeystore is only used in tests

func (*Manager) ImportAccount added in v0.35.0

func (m *Manager) ImportAccount(privateKey *ecdsa.PrivateKey, password string) (types.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)

ImportSingleExtendedKey imports an extended key setting it in both the PrivateKey and ExtendedKey fields of the Key struct. ImportExtendedKey is used in older version of Status where PrivateKey is set to be the BIP44 key at index 0, and ExtendedKey is the extended key of the BIP44 key at index 1.

func (*Manager) Logout

func (m *Manager) Logout()

Logout clears selected accounts.

func (*Manager) MainAccountAddress added in v0.35.0

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

MainAccountAddress returns main account address set during login

func (*Manager) MigrateKeyStoreDir added in v0.55.1

func (m *Manager) MigrateKeyStoreDir(oldDir, newDir string, addresses []string) error

func (*Manager) ReEncryptKey added in v0.80.2

func (m *Manager) ReEncryptKey(rawKey []byte, pass string, newPass string) (reEncryptedKey []byte, e error)

func (*Manager) ReEncryptKeyStoreDir added in v0.80.2

func (m *Manager) ReEncryptKeyStoreDir(keyDirPath, oldPass, newPass string) error

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 types.Address, secondary ...types.Address)

func (*Manager) SetChatAccount added in v0.35.0

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

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) (*types.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() []types.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     types.Address
	AccountKey  *types.Key
	SubAccounts []types.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