accounts

package
v0.0.0-...-404ccd1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package accounts provides types for working with libonomy 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

	NetworkID int8
	// 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 created 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 iff account is locked.

func (*Account) IsAccountUnlocked

func (a *Account) IsAccountUnlocked() bool

IsAccountUnlocked returns true iff 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

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"`
	NetworkID  int8            `json:"networkId"`
}

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