Documentation ¶
Index ¶
- Constants
- func AddNewKeyRequestHandler(indent bool) http.HandlerFunc
- func CheckAndWriteErrorResponse(w http.ResponseWriter, httpErr int, err error) bool
- func Commands() *cobra.Command
- func DeleteKeyRequestHandler(w http.ResponseWriter, r *http.Request)
- func GetKeyInfo(name string) (keys.Info, error)
- func GetKeyRequestHandler(indent bool) http.HandlerFunc
- func GetPassphrase(name string) (string, error)
- func MarshalJSON(o interface{}) ([]byte, error)
- func MnemonicRequestHandler(w http.ResponseWriter, r *http.Request)
- func NewInMemoryKeyBase() keys.Keybase
- func NewKeyBaseFromDir(rootDir string) (keys.Keybase, error)
- func NewKeyBaseFromHomeFlag() (keys.Keybase, error)
- func PostProcessResponse(w http.ResponseWriter, cdc *codec.Codec, response interface{}, indent bool)
- func QueryKeysRequestHandler(indent bool) http.HandlerFunc
- func ReadPassphraseFromStdin(name string) (string, error)
- func RecoverRequestHandler(indent bool) http.HandlerFunc
- func RegisterRoutes(r *mux.Router, indent bool)
- func UnmarshalJSON(bz []byte, ptr interface{}) error
- func UpdateKeyRequestHandler(w http.ResponseWriter, r *http.Request)
- func WriteErrorResponse(w http.ResponseWriter, status int, err string)
- type AddNewKey
- type DeleteKeyBody
- type DeleteKeyReq
- type ErrorResponse
- type KeyOutput
- type RecoverKey
- type UpdateKeyBody
- type UpdateKeyReq
Constants ¶
const ( // FlagAddress is the flag for the user's address on the command line. FlagAddress = "address" // FlagPublicKey represents the user's public key on the command line. FlagPublicKey = "pubkey" // FlagBechPrefix defines a desired Bech32 prefix encoding for a key. FlagBechPrefix = "bech" // FlagDevice indicates that the information should be shown in the device FlagDevice = "device" )
const ( OutputFormatText = "text" OutputFormatJSON = "json" )
available output formats.
const (
// DefaultKeyPass contains the default key password for genesis transactions
DefaultKeyPass = "12345678"
)
Variables ¶
This section is empty.
Functions ¶
func AddNewKeyRequestHandler ¶
func AddNewKeyRequestHandler(indent bool) http.HandlerFunc
add new key REST handler
func CheckAndWriteErrorResponse ¶
func CheckAndWriteErrorResponse(w http.ResponseWriter, httpErr int, err error) bool
CheckAndWriteErrorResponse will check for errors and return a given error message when corresponding TODO: Move to utils/rest or similar
func Commands ¶
Commands registers a sub-tree of commands to interact with local private key storage.
func DeleteKeyRequestHandler ¶
func DeleteKeyRequestHandler(w http.ResponseWriter, r *http.Request)
delete key REST handler
func GetKeyInfo ¶
GetKeyInfo returns key info for a given name. An error is returned if the keybase cannot be retrieved or getting the info fails.
func GetKeyRequestHandler ¶
func GetKeyRequestHandler(indent bool) http.HandlerFunc
get key REST handler
func GetPassphrase ¶
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 MnemonicRequestHandler ¶
func MnemonicRequestHandler(w http.ResponseWriter, r *http.Request)
Mnemonic REST request handler
func NewInMemoryKeyBase ¶
NewInMemoryKeyBase returns a storage-less keybase.
func NewKeyBaseFromDir ¶
NewKeyBaseFromDir initializes a keybase at a particular dir.
func NewKeyBaseFromHomeFlag ¶
NewKeyBaseFromHomeFlag initializes a Keybase based on the configuration.
func PostProcessResponse ¶
func PostProcessResponse(w http.ResponseWriter, cdc *codec.Codec, response interface{}, indent bool)
PostProcessResponse performs post processing for a REST response.
func QueryKeysRequestHandler ¶
func QueryKeysRequestHandler(indent bool) http.HandlerFunc
query key list REST handler
func ReadPassphraseFromStdin ¶
ReadPassphraseFromStdin attempts to read a passphrase from STDIN return an error upon failure.
func RecoverRequestHandler ¶
func RecoverRequestHandler(indent bool) http.HandlerFunc
RecoverRequestHandler performs key recover request
func UpdateKeyRequestHandler ¶
func UpdateKeyRequestHandler(w http.ResponseWriter, r *http.Request)
update key REST handler
func WriteErrorResponse ¶
func WriteErrorResponse(w http.ResponseWriter, status int, err string)
WriteErrorResponse prepares and writes a HTTP error given a status code and an error message.
Types ¶
type AddNewKey ¶
type AddNewKey struct { Name string `json:"name"` Password string `json:"password"` Mnemonic string `json:"mnemonic"` Account int `json:"account,string,omitempty"` Index int `json:"index,string,omitempty"` }
AddNewKey request a new key
func NewAddNewKey ¶
NewAddNewKey constructs a new AddNewKey request structure.
type DeleteKeyBody ¶
type DeleteKeyBody struct {
Password string `json:"password"`
}
delete key request REST body
type DeleteKeyReq ¶
type DeleteKeyReq struct {
Password string `json:"password"`
}
DeleteKeyReq requests deleting a key
func NewDeleteKeyReq ¶
func NewDeleteKeyReq(password string) DeleteKeyReq
NewDeleteKeyReq constructs a new DeleteKeyReq structure.
type ErrorResponse ¶
ErrorResponse defines the attributes of a JSON error response.
func NewErrorResponse ¶
func NewErrorResponse(code int, err string) ErrorResponse
NewErrorResponse creates a new ErrorResponse instance.
type KeyOutput ¶
type KeyOutput struct { Name string `json:"name"` Type string `json:"type"` Address string `json:"address"` PubKey string `json:"pub_key"` Mnemonic string `json:"mnemonic,omitempty"` }
used for outputting keys.Info over REST
func Bech32KeyOutput ¶
create a KeyOutput in bech32 format
type RecoverKey ¶
type RecoverKey struct { Password string `json:"password"` Mnemonic string `json:"mnemonic"` Account int `json:"account,string,omitempty"` Index int `json:"index,string,omitempty"` }
RecoverKeyBody recovers a key
func NewRecoverKey ¶
func NewRecoverKey(password, mnemonic string, account, index int) RecoverKey
NewRecoverKey constructs a new RecoverKey request structure.
type UpdateKeyBody ¶
type UpdateKeyBody struct { NewPassword string `json:"new_password"` OldPassword string `json:"old_password"` }
update key request REST body
type UpdateKeyReq ¶
type UpdateKeyReq struct { OldPassword string `json:"old_password"` NewPassword string `json:"new_password"` }
UpdateKeyReq requests updating a key
func NewUpdateKeyReq ¶
func NewUpdateKeyReq(old, new string) UpdateKeyReq
NewUpdateKeyReq constructs a new UpdateKeyReq structure.