accounts

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWalletNoAccount = errors.New("Wallet does not have any account")
	ErrWalletNotOpen   = errors.New("Wallet is not open")
	ErrWalletIsEmpty   = errors.New("Keystore does not have any wallets")
)

Functions

func LoadKeys

func LoadKeys(keystore, passphrase string) (*ecdsa.PrivateKey, error)

Types

type EthConfig

type EthConfig struct {
	Passphrase string `required:"false" default:"" yaml:"pass_phrase"`
	Keystore   string `required:"false" default:"" yaml:"key_store"`
}

func (*EthConfig) LoadKey

func (c *EthConfig) LoadKey() (*ecdsa.PrivateKey, error)

type Identity

type Identity interface {
	// GetPrivateKey return *ecdsa.PrivateKey, it include PublicKey and ethereum Address shortly
	GetPrivateKey() (*ecdsa.PrivateKey, error)

	// New creates new account in keystore.
	// Do not open created account.
	New(passphrase string) error

	// Open opens loaded account
	Open(passphrase string) error

	// Import imports existing account from given json and pass-phrase
	Import(json []byte, passphrase string) error

	// ImportECDSA imports existing account from given private key and pass-phrase
	ImportECDSA(key *ecdsa.PrivateKey, passphrase string) error
}

Identity interface uses for auth and detect all objects in network source implementation going to go-ethereum accounting its need to be storing wallets in one dir and opened it by passphrase

func NewIdentity

func NewIdentity(keydir string) Identity

NewIdentity creates new identity instance which operates given key storage dir

type KeyOpener

type KeyOpener interface {
	// GetPassPhraser return PassPhraser interface
	// that provides pass phrase for loaded keys
	GetPassPhraser() PassPhraser
	// OpenKeystore opens key storage.
	// bool param is true if keystore was not existed and was created
	OpenKeystore() (bool, error)
	// GetKey returns private key from opened storage
	GetKey() (*ecdsa.PrivateKey, error)
}

KeyOpener is interface for loading Eth keys

func DefaultKeyOpener

func DefaultKeyOpener(p Printer, keyDir, passPhrase string) (KeyOpener, error)

DefaultKeyOpener return KeyOpener configured for using with pre-defined pass-phrase or retrieve pass-phrase interactively

func NewKeyOpener

func NewKeyOpener(keyDir string, pf PassPhraser) KeyOpener

NewKeyOpener returns KeyOpener that able to open keys

type KeyStorager

type KeyStorager interface {
	// KeyStore returns path to key store
	KeyStore() string
	// PassPhrase returns passphrase for keystore
	PassPhrase() string
}

KeyStorager interface describe an item that must know something about a path to the keystore and a passphrase

type PassPhraser

type PassPhraser interface {
	GetPassPhrase() (string, error)
}

PassPhraser is interface for retrieving pass phrase for Eth keys

If you want to retrieve pass phrases reader different ways (e.g: from file, from env variables, interactively from terminal) you must implement PassPhraser reader a different way and pass it to KeyOpener instance

func NewInteractivePassPhraser

func NewInteractivePassPhraser() PassPhraser

NewInteractivePassPhraser implements PassPhraser that prompts user for pass-phrase and read it from terminal's Stdin

func NewStaticPassPhraser

func NewStaticPassPhraser(p string) PassPhraser

type Printer

type Printer interface {
	Printf(format string, i ...interface{})
}

Printer interface describe anything that can print something somehow on a something.

func NewFmtPrinter

func NewFmtPrinter() Printer

func NewSilentPrinter

func NewSilentPrinter() Printer

NewSilentPrinter returns new printer which can prints nothing

Jump to

Keyboard shortcuts

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