account

package
v0.182.43 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MPL-2.0 Imports: 28 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")
	ErrInvalidPersonalSignAccount     = errors.New("invalid account as only the selected one can generate a signature")
)

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 GetRandomMnemonic added in v0.175.1

func GetRandomMnemonic() (string, error)

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 DefaultManager added in v0.159.3

type DefaultManager struct {
	Keydir string
	// contains filtered or unexported fields
}

DefaultManager represents default account manager implementation

func (*DefaultManager) Accounts added in v0.159.3

func (m *DefaultManager) Accounts() ([]types.Address, error)

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

func (*DefaultManager) AccountsGenerator added in v0.159.3

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

AccountsGenerator returns accountsGenerator.

func (*DefaultManager) AddressToDecryptedAccount added in v0.159.3

func (m *DefaultManager) 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 (*DefaultManager) CanRecover added in v0.159.3

func (m *DefaultManager) CanRecover(rpcParams RecoverParams, revealedAddress types.Address) (bool, error)

func (*DefaultManager) CreateAccount added in v0.159.3

func (m *DefaultManager) 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 (*DefaultManager) DeleteAccount added in v0.159.3

func (m *DefaultManager) DeleteAccount(address types.Address) error

func (*DefaultManager) GetKeystore added in v0.159.3

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

GetKeystore is only used in tests

func (*DefaultManager) GetVerifiedWalletAccount added in v0.159.3

func (m *DefaultManager) GetVerifiedWalletAccount(db *accounts.Database, address, password string) (*SelectedExtKey, error)

func (*DefaultManager) ImportAccount added in v0.159.3

func (m *DefaultManager) ImportAccount(privateKey *ecdsa.PrivateKey, password string) (types.Address, error)

ImportAccount imports the account specified with privateKey.

func (*DefaultManager) ImportOnboardingAccount added in v0.159.3

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

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

func (*DefaultManager) ImportSingleExtendedKey added in v0.159.3

func (m *DefaultManager) 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 (*DefaultManager) Logout added in v0.159.3

func (m *DefaultManager) Logout()

Logout clears selected accounts.

func (*DefaultManager) MainAccountAddress added in v0.159.3

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

MainAccountAddress returns main account address set during login

func (*DefaultManager) MigrateKeyStoreDir added in v0.159.3

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

func (*DefaultManager) ReEncryptKey added in v0.159.3

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

func (*DefaultManager) ReEncryptKeyStoreDir added in v0.159.3

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

func (*DefaultManager) Recover added in v0.159.3

func (m *DefaultManager) Recover(rpcParams RecoverParams) (addr types.Address, err error)

func (*DefaultManager) RecoverAccount added in v0.159.3

func (m *DefaultManager) 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 (*DefaultManager) RemoveOnboarding added in v0.159.3

func (m *DefaultManager) RemoveOnboarding()

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

func (*DefaultManager) SelectAccount added in v0.159.3

func (m *DefaultManager) 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 (*DefaultManager) SelectedChatAccount added in v0.159.3

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

SelectedChatAccount returns currently selected chat account

func (*DefaultManager) SetAccountAddresses added in v0.159.3

func (m *DefaultManager) SetAccountAddresses(main types.Address, secondary ...types.Address)

func (*DefaultManager) SetChatAccount added in v0.159.3

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

SetChatAccount initializes selectedChatAccount with privKey

func (*DefaultManager) Sign added in v0.159.3

func (m *DefaultManager) Sign(rpcParams SignParams, verifiedAccount *SelectedExtKey) (result types.HexBytes, err error)

func (*DefaultManager) StartOnboarding added in v0.159.3

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

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

func (*DefaultManager) VerifyAccountPassword added in v0.159.3

func (m *DefaultManager) 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 (*DefaultManager) WatchAddresses added in v0.159.3

func (m *DefaultManager) WatchAddresses() []types.Address

WatchAddresses returns currently selected watch addresses.

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 {
	*DefaultManager
	// 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.

func (*GethManager) SetRPCClient added in v0.138.8

func (m *GethManager) SetRPCClient(rpcClient *rpc.Client, rpcTimeout time.Duration)

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"`
}

type Manager

type Manager interface {
	GetVerifiedWalletAccount(db *accounts.Database, address, password string) (*SelectedExtKey, error)
	Sign(rpcParams SignParams, verifiedAccount *SelectedExtKey) (result types.HexBytes, err error)
	CanRecover(rpcParams RecoverParams, revealedAddress types.Address) (bool, error)
	DeleteAccount(address types.Address) error
}

Manager represents account manager interface

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 RecoverParams added in v0.138.8

type RecoverParams struct {
	Message   string `json:"message"`
	Signature string `json:"signature"`
}

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.

type SignParams added in v0.138.8

type SignParams struct {
	Data     interface{} `json:"data"`
	Address  string      `json:"account"`
	Password string      `json:"password,omitempty"`
}

func (*SignParams) Validate added in v0.171.9

func (sp *SignParams) Validate(checkPassword bool) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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