keys

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const KeyDBName = "keys"

KeyDBName is the directory under root where we store the keys

View Source
const MinPassLength = 8

MinPassLength is the minimum acceptable password length

Variables

This section is empty.

Functions

func BufferStdin

func BufferStdin() *bufio.Reader

BufferStdin is used to allow reading prompts for stdin multiple times, when we read from non-tty

func GetCheckPassword

func GetCheckPassword(prompt, prompt2 string, buf *bufio.Reader) (string, error)

GetCheckPassword will prompt for a password twice to verify they match (for creating a new password). It enforces the password length. Only parses password once if input is piped in.

func GetConfirmation

func GetConfirmation(prompt string, buf *bufio.Reader) (bool, error)

GetConfirmation will request user give the confirmation from stdin. "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again.

func GetKey

func GetKey(name string) (keys.Info, error)

func GetKeyBase

func GetKeyBase() (keys.Keybase, error)

initialize a keybase based on the configuration

func GetKeyBaseFromDB

func GetKeyBaseFromDB(db dbm.DB) keys.Keybase

GetKeyBase initializes a keybase based on the given db. The KeyBase manages all activity requiring access to a key.

func GetKeyBaseFromDir

func GetKeyBaseFromDir(rootDir string) (keys.Keybase, error)

initialize a keybase based on the configuration

func GetKeyInfo

func GetKeyInfo(name string) (keys.Info, error)

GetKeyInfo returns key info for a given name. An error is returned if the keybase cannot be retrieved or getting the info fails.

func GetPassphrase

func GetPassphrase(name string) (string, error)

GetPassphrase returns a passphrase for a given name. It will first retrieve the key info for that name if the type is local, it'll fetch input from STDIN. Otherwise, an empty passphrase is returned. An error is returned if the key info cannot be fetched or reading from STDIN fails.

func GetPassword

func GetPassword(prompt string, buf *bufio.Reader) (pass string, err error)

GetPassword will prompt for a password one-time (to sign a tx) It enforces the password length

func GetSeed

func GetSeed(prompt string, buf *bufio.Reader) (seed string, err error)

GetSeed will request a seed phrase from stdin and trims off leading/trailing spaces

func MockKeyBase

func MockKeyBase() keys.Keybase

MockKeyBase generates an in-memory keybase that will be discarded useful for --dry-run to generate a seed phrase without storing the key

func PrintInfo

func PrintInfo(cdc *wire.Codec, info keys.Info)

func PrintInfos

func PrintInfos(cdc *wire.Codec, infos []keys.Info)

func ReadPassphraseFromStdin

func ReadPassphraseFromStdin(name string) (string, error)

ReadPassphraseFromStdin attempts to read a passphrase from STDIN return an error upon failure.

Types

type KeyOutput

type KeyOutput struct {
	Name    string         `json:"name"`
	Type    string         `json:"type"`
	Address sdk.AccAddress `json:"address"`
	PubKey  string         `json:"pub_key"`
	Seed    string         `json:"seed,omitempty"`
}

used for outputting keys.Info over REST

func Bech32KeyOutput

func Bech32KeyOutput(info keys.Info) (KeyOutput, error)

create a KeyOutput in bech32 format

func Bech32KeysOutput

func Bech32KeysOutput(infos []keys.Info) ([]KeyOutput, error)

create a list of KeyOutput in bech32 format

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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