Documentation ¶
Overview ¶
Package accounts defines account-related helper methods and types. The accounts database, for example, is defined in this package.
Package accounts defines account-related helper methods and types. The accounts database, for example, is defined in this package.
Index ¶
- Variables
- type Account
- type DB
- func (db *DB) AddNewAccount(name string, password string, address string) (*Account, error)
- func (db *DB) Auth(name string, password string) bool
- func (db *DB) CloseDB() error
- func (db *DB) CreateAccountsBucketIfNotExist() error
- func (db *DB) CreateNewAccount(name string, password string) (*Account, error)
- func (db *DB) DeleteAccount(name string, password string) error
- func (db *DB) GetUserBalance(username string) (*big.Float, error)
- func (db *DB) GetUserTransactions(username string) ([]*types.Transaction, error)
- func (db *DB) IssueAccountToken(username, password string) (string, error)
- func (db *DB) MakeFaucetClaim(account *Account, amount *big.Float) error
- func (db *DB) QueryAccountByAddress(address summercashCommon.Address) (*Account, error)
- func (db *DB) QueryAccountByUsername(name string) (*Account, error)
- func (db *DB) ResetAccountPassword(name string, oldPassword string, newPassword string) error
- func (db *DB) ValidateAccountToken(account *Account, token string) bool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAccountAlreadyExists is an error definition describing an attempted duplicate put. ErrAccountAlreadyExists = errors.New("account already exists") // ErrAccountDoesNotExist is an error definition describing an account value of nil. ErrAccountDoesNotExist = errors.New("no account exists with the given username") // ErrPasswordInvalid is an error definition describing an invalid password value. ErrPasswordInvalid = errors.New("invalid password") )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Name string `json:"name"` // Name PasswordHash []byte `json:"password_hash"` // Password hash Address common.Address `json:"address"` // Address LastFaucetClaimTime time.Time `json:"last_claim_time"` // Last claim time LastFaucetClaimAmount *big.Float `json:"last_claim_amount"` // Last claim amount Tokens []string `json:"tokens"` // Account tokens FcmTokens []string `json:"fcm_tokens"` // Account Firebase Cloud Messaging tokens }
Account represents a username-password keypair linking to a private key in the accounts database.
func AccountFromBytes ¶
AccountFromBytes deserializes an account from a given byte array.
type DB ¶
DB is a data type representing a link to a working accounts boltdb instance.
func (*DB) AddNewAccount ¶
AddNewAccount adds a new account to the list of accounts in the working database.
func (*DB) CreateAccountsBucketIfNotExist ¶
CreateAccountsBucketIfNotExist creates the accounts bucket if it doesn't already exist.
func (*DB) CreateNewAccount ¶
CreateNewAccount creates a new account with a given name and password. Returns the new account's address and an error (if applicable).
func (*DB) DeleteAccount ¶ added in v0.5.8
DeleteAccount deletes an account from the working DB.
func (*DB) GetUserBalance ¶
GetUserBalance calculates the balance of a particular account.
func (*DB) GetUserTransactions ¶
func (db *DB) GetUserTransactions(username string) ([]*types.Transaction, error)
GetUserTransactions fetches the list of transactions for a particular account.
func (*DB) IssueAccountToken ¶ added in v0.5.9
IssueAccountToken issues a new account token.
func (*DB) MakeFaucetClaim ¶ added in v0.5.8
MakeFaucetClaim makes a faucet claim for a given account.
func (*DB) QueryAccountByAddress ¶ added in v0.5.8
func (db *DB) QueryAccountByAddress(address summercashCommon.Address) (*Account, error)
QueryAccountByAddress queries the database for an account with a given address.
func (*DB) QueryAccountByUsername ¶
QueryAccountByUsername queries the database for an account with a given username.
func (*DB) ResetAccountPassword ¶
ResetAccountPassword resets an accounts password.