accounts

package
v0.154.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SyncedFromBackup       = "backup"        // means a account is coming from backed up data
	SyncedFromLocalPairing = "local-pairing" // means a account is coming from another device when user is reocovering Status account
)
View Source
const (
	// NodeConfigTag tag for a node configuration.
	NodeConfigTag = "node_config"
)

Variables

View Source
var (
	ErrDbKeypairNotFound              = errors.New("accounts: keypair is not found")
	ErrDbAccountNotFound              = errors.New("accounts: account is not found")
	ErrKeypairDifferentAccountsKeyUID = errors.New("cannot store keypair with different accounts' key uid than keypair's key uid")
	ErrKeypairWithoutAccounts         = errors.New("cannot store keypair without accounts")
)

Functions

func AddTestAccounts added in v0.152.2

func AddTestAccounts(t *testing.T, db *sql.DB, accounts []*Account)

func SameAccounts added in v0.152.2

func SameAccounts(expected, real *Account) bool

func SameAccountsWithDifferentOperable added in v0.152.2

func SameAccountsWithDifferentOperable(expected, real *Account, expectedOperableValue AccountOperable) bool

func SameKeycards added in v0.152.2

func SameKeycards(expected, real *Keycard) bool

func SameKeypairs added in v0.152.2

func SameKeypairs(expected, real *Keypair) bool

func SameKeypairsWithDifferentSyncedFrom added in v0.152.2

func SameKeypairsWithDifferentSyncedFrom(expected, real *Keypair, ignoreSyncedFrom bool, expectedSyncedFromValue string,
	expectedOperableValue AccountOperable) bool

Types

type Account

type Account struct {
	Address   types.Address             `json:"address"`
	KeyUID    string                    `json:"key-uid"`
	Wallet    bool                      `json:"wallet"`
	Chat      bool                      `json:"chat"`
	Type      AccountType               `json:"type,omitempty"`
	Path      string                    `json:"path,omitempty"`
	PublicKey types.HexBytes            `json:"public-key,omitempty"`
	Name      string                    `json:"name"`
	Emoji     string                    `json:"emoji"`
	ColorID   common.CustomizationColor `json:"colorId,omitempty"`
	Hidden    bool                      `json:"hidden"`
	Clock     uint64                    `json:"clock,omitempty"`
	Removed   bool                      `json:"removed,omitempty"`
	Operable  AccountOperable           `json:"operable"` // describes an account's operability (read an explanation at the top of this file)
	CreatedAt int64                     `json:"createdAt"`
}

func GetWatchOnlyAccountsForTest added in v0.152.2

func GetWatchOnlyAccountsForTest() []*Account

func (*Account) IsOwnAccount added in v0.64.6

func (a *Account) IsOwnAccount() bool

IsOwnAccount returns true if this is an account we have the private key for NOTE: Wallet flag can't be used as it actually indicates that it's the default Wallet

func (*Account) MarshalJSON added in v0.100.0

func (a *Account) MarshalJSON() ([]byte, error)

type AccountOperable added in v0.152.2

type AccountOperable string
const (
	AccountNonOperable       AccountOperable = "no"        // an account is non operable it is not a keycard account and there is no keystore file for it and no keystore file for the address it is derived from
	AccountPartiallyOperable AccountOperable = "partially" // an account is partially operable if it is not a keycard account and there is created keystore file for the address it is derived from
	AccountFullyOperable     AccountOperable = "fully"     // an account is fully operable if it is not a keycard account and there is a keystore file for it
)

func (AccountOperable) String added in v0.152.2

func (a AccountOperable) String() string

type AccountType added in v0.106.3

type AccountType string
const (
	AccountTypeGenerated AccountType = "generated"
	AccountTypeKey       AccountType = "key"
	AccountTypeSeed      AccountType = "seed"
	AccountTypeWatch     AccountType = "watch"
)

func (AccountType) String added in v0.106.3

func (a AccountType) String() string

type Database

type Database struct {
	*settings.Database
	*notificationssettings.NotificationsSettings
	*sociallinkssettings.SocialLinksSettings
	*Keycards
	// contains filtered or unexported fields
}

Database sql wrapper for operations with browser objects.

func NewDB

func NewDB(db *sql.DB) (*Database, error)

NewDB returns a new instance of *Database

func (*Database) AddressExists

func (db *Database) AddressExists(address types.Address) (exists bool, err error)

AddressExists returns true if given address is stored in database.

func (*Database) Close

func (db *Database) Close() error

Close closes database.

func (*Database) DB added in v0.93.2

func (db *Database) DB() *sql.DB

DB Gets db sql.DB

func (*Database) DeleteAccount added in v0.38.1

func (db *Database) DeleteAccount(address types.Address) error

func (*Database) DeleteKeypair added in v0.152.2

func (db *Database) DeleteKeypair(keyUID string) error

func (*Database) GetAccountByAddress added in v0.62.16

func (db *Database) GetAccountByAddress(address types.Address) (*Account, error)

func (*Database) GetAccounts

func (db *Database) GetAccounts() ([]*Account, error)

func (*Database) GetAddresses

func (db *Database) GetAddresses() (rst []types.Address, err error)

func (*Database) GetChatAddress

func (db *Database) GetChatAddress() (rst types.Address, err error)

func (*Database) GetKeypairByKeyUID added in v0.152.2

func (db *Database) GetKeypairByKeyUID(keyUID string) (*Keypair, error)

func (*Database) GetKeypairs added in v0.152.2

func (db *Database) GetKeypairs() ([]*Keypair, error)

func (*Database) GetNodeConfig added in v0.38.4

func (db *Database) GetNodeConfig() (*params.NodeConfig, error)

func (*Database) GetPath added in v0.102.6

func (db *Database) GetPath(address types.Address) (path string, err error)

GetPath returns true if account with given address was recently key and doesn't have a key yet

func (*Database) GetWalletAddress

func (db *Database) GetWalletAddress() (rst types.Address, err error)

func (*Database) GetWalletAddresses added in v0.40.0

func (db *Database) GetWalletAddresses() (rst []types.Address, err error)

func (*Database) GetWatchOnlyAccounts added in v0.152.2

func (db *Database) GetWatchOnlyAccounts() (res []*Account, err error)

func (*Database) IsAnyAccountPartalyOrFullyOperableForKeyUID added in v0.152.2

func (db *Database) IsAnyAccountPartalyOrFullyOperableForKeyUID(keyUID string) (bool, error)

func (*Database) SaveOrUpdateAccounts added in v0.152.2

func (db *Database) SaveOrUpdateAccounts(accounts []*Account) error

func (*Database) SaveOrUpdateKeypair added in v0.152.2

func (db *Database) SaveOrUpdateKeypair(keypair *Keypair) error

func (*Database) UpdateAccountToFullyOperable added in v0.152.2

func (db *Database) UpdateAccountToFullyOperable(keyUID string, address types.Address) (err error)

this doesn't update clock

func (*Database) UpdateKeypairName added in v0.152.2

func (db *Database) UpdateKeypairName(keyUID string, name string, clock uint64) error

type Keycard added in v0.152.2

type Keycard struct {
	KeycardUID        string          `json:"keycard-uid"`
	KeycardName       string          `json:"keycard-name"`
	KeycardLocked     bool            `json:"keycard-locked"`
	AccountsAddresses []types.Address `json:"accounts-addresses"`
	KeyUID            string          `json:"key-uid"`
	LastUpdateClock   uint64
}

func GetKeycardForSeedImportedKeypair1ForTest added in v0.152.2

func GetKeycardForSeedImportedKeypair1ForTest() *Keycard

func GetKeycardForSeedImportedKeypair2ForTest added in v0.152.2

func GetKeycardForSeedImportedKeypair2ForTest() *Keycard

func GetProfileKeycardForTest added in v0.152.2

func GetProfileKeycardForTest() *Keycard

func (*Keycard) FromSyncKeycard added in v0.152.2

func (kp *Keycard) FromSyncKeycard(kc *protobuf.SyncKeycard)

func (*Keycard) ToSyncKeycard added in v0.152.2

func (kp *Keycard) ToSyncKeycard() *protobuf.SyncKeycard

type KeycardAction added in v0.152.2

type KeycardAction struct {
	Action        string   `json:"action"`
	OldKeycardUID string   `json:"old-keycard-uid,omitempty"`
	Keycard       *Keycard `json:"keycard"`
}

type Keycards added in v0.152.2

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

func NewKeycards added in v0.152.2

func NewKeycards(db *sql.DB) *Keycards

func (*Keycards) AddKeycardOrAddAccountsIfKeycardIsAdded added in v0.152.2

func (kp *Keycards) AddKeycardOrAddAccountsIfKeycardIsAdded(keycard Keycard) (addedKc bool, addedAccs bool, err error)

func (*Keycards) ApplyKeycardsForKeypairWithKeyUID added in v0.152.2

func (kp *Keycards) ApplyKeycardsForKeypairWithKeyUID(keyUID string, keycardsToSync []*Keycard) (err error)

func (*Keycards) DeleteAllKeycardsWithKeyUID added in v0.152.2

func (kp *Keycards) DeleteAllKeycardsWithKeyUID(keyUID string) (err error)

func (*Keycards) DeleteKeycard added in v0.152.2

func (kp *Keycards) DeleteKeycard(kcUID string, clock uint64) (err error)

func (*Keycards) GetAllKnownKeycards added in v0.152.2

func (kp *Keycards) GetAllKnownKeycards() ([]*Keycard, error)

func (*Keycards) GetAllKnownKeycardsGroupedByKeyUID added in v0.152.2

func (kp *Keycards) GetAllKnownKeycardsGroupedByKeyUID() ([]*Keycard, error)

func (*Keycards) GetKeycardByKeyUID added in v0.152.2

func (kp *Keycards) GetKeycardByKeyUID(keyUID string) ([]*Keycard, error)

func (*Keycards) KeycardLocked added in v0.152.2

func (kp *Keycards) KeycardLocked(kcUID string, clock uint64) (err error)

func (*Keycards) KeycardUnlocked added in v0.152.2

func (kp *Keycards) KeycardUnlocked(kcUID string, clock uint64) (err error)

func (*Keycards) RemoveMigratedAccountsForKeycard added in v0.152.2

func (kp *Keycards) RemoveMigratedAccountsForKeycard(kcUID string, accountAddresses []types.Address,
	clock uint64) (err error)

func (*Keycards) SetKeycardName added in v0.152.2

func (kp *Keycards) SetKeycardName(kcUID string, kpName string, clock uint64) (err error)

func (*Keycards) UpdateKeycardUID added in v0.152.2

func (kp *Keycards) UpdateKeycardUID(oldKcUID string, newKcUID string, clock uint64) (err error)

type Keypair added in v0.152.2

type Keypair struct {
	KeyUID                  string      `json:"key-uid"`
	Name                    string      `json:"name"`
	Type                    KeypairType `json:"type"`
	DerivedFrom             string      `json:"derived-from"`
	LastUsedDerivationIndex uint64      `json:"last-used-derivation-index,omitempty"`
	SyncedFrom              string      `json:"synced-from,omitempty"` // keeps an info which device this keypair is added from can be one of two values defined in constants or device name (custom)
	Clock                   uint64      `json:"clock,omitempty"`
	Accounts                []*Account  `json:"accounts"`
}

func GetPrivKeyImportedKeypairForTest added in v0.152.2

func GetPrivKeyImportedKeypairForTest() *Keypair

func GetProfileKeypairForTest added in v0.152.2

func GetProfileKeypairForTest(includeChatAccount bool, includeDefaultWalletAccount bool, includeAdditionalAccounts bool) *Keypair

func GetSeedImportedKeypair1ForTest added in v0.152.2

func GetSeedImportedKeypair1ForTest() *Keypair

func GetSeedImportedKeypair2ForTest added in v0.152.2

func GetSeedImportedKeypair2ForTest() *Keypair

func (*Keypair) CopyKeypair added in v0.152.2

func (a *Keypair) CopyKeypair() *Keypair

func (*Keypair) GetChatPublicKey added in v0.154.2

func (a *Keypair) GetChatPublicKey() types.HexBytes

func (*Keypair) MarshalJSON added in v0.152.2

func (a *Keypair) MarshalJSON() ([]byte, error)

type KeypairType added in v0.152.2

type KeypairType string
const (
	KeypairTypeProfile KeypairType = "profile"
	KeypairTypeKey     KeypairType = "key"
	KeypairTypeSeed    KeypairType = "seed"
)

func (KeypairType) String added in v0.152.2

func (a KeypairType) String() string

Jump to

Keyboard shortcuts

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