accounts

package
v0.0.0-...-42befb5 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package accounts provides types for working with Spacemesh blockchain accounts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadAllAccounts

func LoadAllAccounts() error

LoadAllAccounts loads all account persisted to store

Types

type Account

type Account struct {
	PrivKey crypto.PrivateKey
	PubKey  crypto.PublicKey
	// contains filtered or unexported fields
}

Account is an end user blockchain account.

func NewAccount

func NewAccount(passphrase string) (*Account, error)

NewAccount Creates a new account using the provided passphrase. Clients should persist newly create accounts - without this the account only lasts for one app session.

func NewAccountFromStore

func NewAccountFromStore(accountID string, accountsDataPath string) (*Account, error)

NewAccountFromStore creates a new account by id and stored data. Account will be locked after creation as there's no persisted passphrase. accountsDataPath: os-specific full path to accounts data folder.

func (*Account) IsAccountLocked

func (a *Account) IsAccountLocked() bool

IsAccountLocked returns true if account is locked.

func (*Account) IsAccountUnlocked

func (a *Account) IsAccountUnlocked() bool

IsAccountUnlocked returns true if account is unlocked.

func (*Account) LockAccount

func (a *Account) LockAccount(passphrase string)

LockAccount locks an account with user provided passphrase.

func (*Account) Log

func (a *Account) Log()

Log account info.

func (*Account) Persist

func (a *Account) Persist(accountsDataPath string) (string, error)

Persist all account data to store Passphrases are never persisted to store accountsDataPath: os-specific full path to accounts data folder Returns full path of persisted file (useful for testing)

func (*Account) Pretty

func (a *Account) Pretty() string

Pretty returns an account logging string.

func (*Account) String

func (a *Account) String() string

String returns the stringed data of the account public key.

func (*Account) UnlockAccount

func (a *Account) UnlockAccount(passphrase string) error

UnlockAccount unlocks an account using the user provided passphrase.

type AccountData

type AccountData struct {
	PublicKey  string          `json:"publicKey"`
	CryptoData CryptoData      `json:"crypto"`
	KDParams   crypto.KDParams `json:"kd"`
}

AccountData is used to persist an account.

type CryptoData

type CryptoData struct {
	Cipher     string `json:"cipher"`
	CipherText string `json:"cipherText"` // encrypted private key
	CipherIv   string `json:"cipherIv"`
	Mac        string `json:"mac"`
}

CryptoData is the data use to encrypt/decrypt locally stored account data.

type Registry

type Registry struct {
	All      map[string]*Account
	Unlocked map[string]*Account
}

Registry maintains a list of known locked and unlocked accounts.

var (
	// Accounts Registry app singleton.
	Accounts *Registry
)

Jump to

Keyboard shortcuts

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