Documentation
¶
Index ¶
- Constants
- Variables
- func GetDefaultKeyStoreDir() (string, error)
- func LoadKeys(keystore, passphrase string, options ...Option) (*ecdsa.PrivateKey, error)
- type EthConfig
- type Identity
- type KeyOpener
- type KeyStorager
- type KeystoreConfig
- type MultiKeystore
- func (m *MultiKeystore) Generate() (*ecdsa.PrivateKey, error)
- func (m *MultiKeystore) GenerateWithPassword(pass string) (*ecdsa.PrivateKey, error)
- func (m *MultiKeystore) GetDefault() (*ecdsa.PrivateKey, error)
- func (m *MultiKeystore) GetDefaultAddress() (common.Address, error)
- func (m *MultiKeystore) GetKeyByAddress(addr common.Address) (*ecdsa.PrivateKey, error)
- func (m *MultiKeystore) GetKeyWithPass(addr common.Address, pass string) (*ecdsa.PrivateKey, error)
- func (m *MultiKeystore) List() []accounts.Account
- func (m *MultiKeystore) SetDefault(addr common.Address) error
- type Option
- type PassPhraser
- type Printer
Constants ¶
const ( HomeConfigDir = ".sonm" DefaultKeystorePath = "keystore" )
Variables ¶
Functions ¶
func GetDefaultKeyStoreDir ¶
Types ¶
type EthConfig ¶
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 ¶
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 did not exist 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 ¶
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 KeystoreConfig ¶ added in v0.4.1
type MultiKeystore ¶ added in v0.4.1
type MultiKeystore struct {
// contains filtered or unexported fields
}
func NewMultiKeystore ¶ added in v0.4.1
func NewMultiKeystore(cfg *KeystoreConfig, pf PassPhraser) (*MultiKeystore, error)
func (*MultiKeystore) Generate ¶ added in v0.4.1
func (m *MultiKeystore) Generate() (*ecdsa.PrivateKey, error)
Generate creates new key into keystore
func (*MultiKeystore) GenerateWithPassword ¶ added in v0.4.1
func (m *MultiKeystore) GenerateWithPassword(pass string) (*ecdsa.PrivateKey, error)
GenerateWithPassword generates new key with given pass-phrase
func (*MultiKeystore) GetDefault ¶ added in v0.4.1
func (m *MultiKeystore) GetDefault() (*ecdsa.PrivateKey, error)
GetDefault returns default key for the keystore
func (*MultiKeystore) GetDefaultAddress ¶ added in v0.4.1
func (m *MultiKeystore) GetDefaultAddress() (common.Address, error)
func (*MultiKeystore) GetKeyByAddress ¶ added in v0.4.1
func (m *MultiKeystore) GetKeyByAddress(addr common.Address) (*ecdsa.PrivateKey, error)
GetKeyByAddress loads and decrypts key form keystore (if present)
func (*MultiKeystore) GetKeyWithPass ¶ added in v0.4.1
func (m *MultiKeystore) GetKeyWithPass(addr common.Address, pass string) (*ecdsa.PrivateKey, error)
func (*MultiKeystore) List ¶ added in v0.4.1
func (m *MultiKeystore) List() []accounts.Account
List returns list of accounts addresses into keystore
func (*MultiKeystore) SetDefault ¶ added in v0.4.1
func (m *MultiKeystore) SetDefault(addr common.Address) error
SetDefault marks key as default for keystore
type PassPhraser ¶
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