account

package
v0.26.0-alpha.33 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: MPL-2.0 Imports: 17 Imported by: 20

Documentation

Overview

Package account is a generated GoMock package.

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")
)

errors

View Source
var (
	ErrInvalidAccountAddressOrKey = errors.New("cannot parse address or key to valid account address")
)

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 GethServiceProvider

type GethServiceProvider interface {
	AccountManager() (*accounts.Manager, error)
	AccountKeyStore() (*keystore.KeyStore, error)
}

GethServiceProvider provides required geth services.

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 Manager

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

Manager represents account manager interface.

func NewManager

func NewManager(geth GethServiceProvider) *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) 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) CreateChildAccount

func (m *Manager) CreateChildAccount(parentAddress, password string) (address, pubKey string, err error)

CreateChildAccount creates sub-account for an account identified by parent address. CKD#2 is used as root for master accounts (when parentAddress is ""). Otherwise (when parentAddress != ""), child is derived directly from parent.

func (*Manager) Logout

func (m *Manager) Logout()

Logout clears selectedWalletAccount.

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) SelectAccount

func (m *Manager) SelectAccount(walletAddress, chatAddress, password string) 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) SelectedWalletAccount

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

SelectedWalletAccount returns currently selected wallet account

func (*Manager) SetChatAccount added in v0.35.0

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

SetChatAccount initializes selectedChatAccount with privKey

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.

type MockGethServiceProvider

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

MockGethServiceProvider is a mock of GethServiceProvider interface

func NewMockGethServiceProvider

func NewMockGethServiceProvider(ctrl *gomock.Controller) *MockGethServiceProvider

NewMockGethServiceProvider creates a new mock instance

func (*MockGethServiceProvider) AccountKeyStore

func (m *MockGethServiceProvider) AccountKeyStore() (*keystore.KeyStore, error)

AccountKeyStore mocks base method

func (*MockGethServiceProvider) AccountManager

func (m *MockGethServiceProvider) AccountManager() (*accounts.Manager, error)

AccountManager mocks base method

func (*MockGethServiceProvider) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

type MockGethServiceProviderMockRecorder

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

MockGethServiceProviderMockRecorder is the mock recorder for MockGethServiceProvider

func (*MockGethServiceProviderMockRecorder) AccountKeyStore

func (mr *MockGethServiceProviderMockRecorder) AccountKeyStore() *gomock.Call

AccountKeyStore indicates an expected call of AccountKeyStore

func (*MockGethServiceProviderMockRecorder) AccountManager

func (mr *MockGethServiceProviderMockRecorder) AccountManager() *gomock.Call

AccountManager indicates an expected call of AccountManager

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.

Jump to

Keyboard shortcuts

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