keys

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: Apache-2.0 Imports: 17 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 ErrKeyNameConflict added in v0.7.0

func ErrKeyNameConflict(name string) error

func ErrMissingName added in v0.7.0

func ErrMissingName() error

func ErrMissingPassword added in v0.7.0

func ErrMissingPassword() error

func ErrMissingSeed added in v0.7.0

func ErrMissingSeed() error

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 GetKeyBaseFromDirWithWritePerm added in v0.7.0

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

GetKeyBaseFromDirWithWritePerm initializes a keybase at a particular dir with write permissions.

func GetKeyBaseWithWritePerm added in v0.7.0

func GetKeyBaseWithWritePerm() (keys.Keybase, error)

GetKeyBaseWithWritePerm initialize a keybase based on the configuration with write permissions.

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 InputIsTty added in v0.15.0

func InputIsTty() bool

inputIsTty returns true iff we have an interactive prompt, where we can disable echo and request to repeat the password. If false, we can optimize for piped input from another command

func MarshalJSON

func MarshalJSON(o interface{}) ([]byte, error)

marshal keys

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 PostProcessResponse added in v0.7.0

func PostProcessResponse(w http.ResponseWriter, cdc *codec.Codec, response interface{}, indent bool)

PostProcessResponse performs post process for rest response

func PrintInfos

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

func PrintKeyAddress added in v0.7.0

func PrintKeyAddress(info keys.Info, bechKeyOut BechKeyOutFn)

func PrintKeyInfo added in v0.7.0

func PrintKeyInfo(keyInfo keys.Info, bechKeyOut BechKeyOutFn)

func PrintKeyOutput added in v0.7.0

func PrintKeyOutput(ko KeyOutput)

func PrintPubKey added in v0.7.0

func PrintPubKey(info keys.Info, bechKeyOut BechKeyOutFn)

func ReadKeystorePassphraseFromStdin added in v0.15.0

func ReadKeystorePassphraseFromStdin() (string, error)

func ReadPassphraseFromStdin

func ReadPassphraseFromStdin(name string) (string, error)

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

func UnmarshalJSON

func UnmarshalJSON(bz []byte, ptr interface{}) error

unmarshal json

Types

type BechKeyOutFn added in v0.7.0

type BechKeyOutFn func(keyInfo keys.Info) (KeyOutput, error)

func GetBechKeyOut added in v0.7.0

func GetBechKeyOut(bechPrefix string) (BechKeyOutFn, error)

type KeyOutput

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

used for outputting keys.Info over REST

func Bech32ConsKeyOutput added in v0.7.0

func Bech32ConsKeyOutput(keyInfo keys.Info) (KeyOutput, error)

Bech32ConsKeyOutput returns key output for a consensus node's key information.

func Bech32KeyOutput

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

Bech32KeyOutput create a KeyOutput in bech32 format

func Bech32KeysOutput

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

create a list of KeyOutput in bech32 format

func Bech32ValKeyOutput added in v0.7.0

func Bech32ValKeyOutput(keyInfo keys.Info) (KeyOutput, error)

Bech32ValKeyOutput returns key output for a validator's key information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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