2018-02-22 07:17:19 -08:00
|
|
|
package keys
|
|
|
|
|
|
|
|
import (
|
2018-02-23 02:25:25 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
2018-03-09 01:15:56 -08:00
|
|
|
"github.com/gorilla/mux"
|
2018-02-22 07:17:19 -08:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2018-02-22 08:20:25 -08:00
|
|
|
// Commands registers a sub-tree of commands to interact with
|
|
|
|
// local private key storage.
|
|
|
|
func Commands() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "keys",
|
|
|
|
Short: "Add or view local private keys",
|
|
|
|
Long: `Keys allows you to manage your local keystore for tendermint.
|
2018-02-22 07:17:19 -08:00
|
|
|
|
2018-02-22 08:20:25 -08:00
|
|
|
These keys may be in any format supported by go-crypto and can be
|
|
|
|
used by light-clients, full nodes, or any other application that
|
|
|
|
needs to sign with a private key.`,
|
|
|
|
}
|
|
|
|
cmd.AddCommand(
|
|
|
|
addKeyCommand(),
|
|
|
|
listKeysCmd,
|
2018-08-30 21:06:44 -07:00
|
|
|
showKeysCmd(),
|
2018-02-23 02:25:25 -08:00
|
|
|
client.LineBreak,
|
2018-02-22 08:20:25 -08:00
|
|
|
deleteKeyCommand(),
|
|
|
|
updateKeyCommand(),
|
|
|
|
)
|
|
|
|
return cmd
|
2018-02-22 07:17:19 -08:00
|
|
|
}
|
2018-03-09 01:15:56 -08:00
|
|
|
|
2018-04-18 21:49:24 -07:00
|
|
|
// resgister REST routes
|
2018-03-09 01:15:56 -08:00
|
|
|
func RegisterRoutes(r *mux.Router) {
|
|
|
|
r.HandleFunc("/keys", QueryKeysRequestHandler).Methods("GET")
|
|
|
|
r.HandleFunc("/keys", AddNewKeyRequestHandler).Methods("POST")
|
|
|
|
r.HandleFunc("/keys/seed", SeedRequestHandler).Methods("GET")
|
|
|
|
r.HandleFunc("/keys/{name}", GetKeyRequestHandler).Methods("GET")
|
|
|
|
r.HandleFunc("/keys/{name}", UpdateKeyRequestHandler).Methods("PUT")
|
|
|
|
r.HandleFunc("/keys/{name}", DeleteKeyRequestHandler).Methods("DELETE")
|
|
|
|
}
|