diff --git a/Gopkg.lock b/Gopkg.lock index 38830c49e9d2..73a2ff60fdef 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -490,6 +490,14 @@ revision = "013b9cef642f875634c614019ab13b17570778ad" version = "v0.23.0" +[[projects]] + digest = "1:bf6d9a827ea3cad964c2f863302e4f6823170d0b5ed16f72cf1184a7c615067e" + name = "github.com/tendermint/tmlibs" + packages = ["cli"] + pruneopts = "UT" + revision = "49596e0a1f48866603813df843c9409fc19805c6" + version = "v0.9.0" + [[projects]] digest = "1:4dcb0dd65feecb068ce23a234d1a07c7868a1e39f52a6defcae0bb371d03abf6" name = "github.com/zondax/ledger-goclient" @@ -499,7 +507,7 @@ [[projects]] branch = "master" - digest = "1:7a71fffde456d746c52f9cd09c50b034533a3180fb1f6320abb149f2ccc579e5" + digest = "1:27507554c6d4f060d8d700c31c624a43d3a92baa634e178ddc044bdf7d13b44a" name = "golang.org/x/crypto" packages = [ "blowfish", @@ -518,7 +526,7 @@ "salsa20/salsa", ] pruneopts = "UT" - revision = "aabede6cba87e37f413b3e60ebfc214f8eeca1b0" + revision = "614d502a4dac94afa3a6ce146bd1736da82514c6" [[projects]] digest = "1:d36f55a999540d29b6ea3c2ea29d71c76b1d9853fdcd3e5c5cb4836f2ba118f1" @@ -538,14 +546,14 @@ [[projects]] branch = "master" - digest = "1:ead82e3e398388679f3ad77633a087ac31a47a6be59ae20841e1d1b3a3fbbd22" + digest = "1:a0e12bc26f317c0e2d497baf767285e1790e526e8dd46553c5a67fcbc8692157" name = "golang.org/x/sys" packages = [ "cpu", "unix", ] pruneopts = "UT" - revision = "1a700e749ce29638d0bbcb531cce1094ea096bd3" + revision = "3b58ed4ad3395d483fc92d5d14123ce2c3581fec" [[projects]] digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18" @@ -666,6 +674,7 @@ "github.com/tendermint/tendermint/rpc/lib/server", "github.com/tendermint/tendermint/types", "github.com/tendermint/tendermint/version", + "github.com/tendermint/tmlibs/cli", "github.com/zondax/ledger-goclient", "golang.org/x/crypto/blowfish", "golang.org/x/crypto/ripemd160", diff --git a/PENDING.md b/PENDING.md index 5b3d5fc8572d..ba4772fa240a 100644 --- a/PENDING.md +++ b/PENDING.md @@ -8,9 +8,12 @@ BREAKING CHANGES * Gaia CLI (`gaiacli`) * [x/stake] Validator.Owner renamed to Validator.Operator * [cli] unsafe_reset_all, show_validator, and show_node_id have been renamed to unsafe-reset-all, show-validator, and show-node-id + * [cli] \#1983 --print-response now defaults to true in commands that create and send a transaction + * [cli] \#1983 you can now pass --pubkey or --address to gaiacli keys show to return a plaintext representation of the key's address or public key for use with other commands * [cli] \#2061 changed proposalID in governance REST endpoints to proposal-id * [cli] \#2014 `gaiacli advanced` no longer exists - to access `ibc`, `rest-server`, and `validator-set` commands use `gaiacli ibc`, `gaiacli rest-server`, and `gaiacli tendermint`, respectively + * Gaia * Make the transient store key use a distinct store key. [#2013](https://github.com/cosmos/cosmos-sdk/pull/2013) * [x/stake] \#1901 Validator type's Owner field renamed to Operator; Validator's GetOwner() renamed accordingly to comply with the SDK's Validator interface. diff --git a/client/flags.go b/client/flags.go index 8616f9e78d4a..b020789057f6 100644 --- a/client/flags.go +++ b/client/flags.go @@ -52,7 +52,7 @@ func PostCommands(cmds ...*cobra.Command) []*cobra.Command { c.Flags().Int64(FlagGas, 200000, "gas limit to set per-transaction") c.Flags().Bool(FlagAsync, false, "broadcast transactions asynchronously") c.Flags().Bool(FlagJson, false, "return output in json format") - c.Flags().Bool(FlagPrintResponse, false, "return tx response (only works with async = false)") + c.Flags().Bool(FlagPrintResponse, true, "return tx response (only works with async = false)") } return cmds } diff --git a/client/keys/show.go b/client/keys/show.go index 873c45a4b605..7dbbc3028ee9 100644 --- a/client/keys/show.go +++ b/client/keys/show.go @@ -4,10 +4,20 @@ import ( "encoding/json" "net/http" - keys "github.com/cosmos/cosmos-sdk/crypto/keys" + "github.com/cosmos/cosmos-sdk/crypto/keys" "github.com/gorilla/mux" "github.com/spf13/cobra" + "github.com/spf13/viper" + "github.com/pkg/errors" + "github.com/tendermint/tmlibs/cli" +) + +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" ) var showKeysCmd = &cobra.Command{ @@ -18,13 +28,38 @@ var showKeysCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { name := args[0] info, err := getKey(name) - if err == nil { - printInfo(info) + if err != nil { + return err + } + + showAddress := viper.GetBool(FlagAddress) + showPublicKey := viper.GetBool(FlagPublicKey) + outputSet := cmd.Flag(cli.OutputFlag).Changed + if showAddress && showPublicKey { + return errors.New("cannot use both --address and --pubkey at once") + } + if outputSet && (showAddress || showPublicKey) { + return errors.New("cannot use --output with --address or --pubkey") } - return err + if showAddress { + printKeyAddress(info) + return nil + } + if showPublicKey { + printPubKey(info) + return nil + } + + printInfo(info) + return nil }, } +func init() { + showKeysCmd.Flags().Bool(FlagAddress, false, "output the address only (overrides --output)") + showKeysCmd.Flags().Bool(FlagPublicKey, false, "output the public key only (overrides --output)") +} + func getKey(name string) (keys.Info, error) { kb, err := GetKeyBase() if err != nil { diff --git a/client/keys/utils.go b/client/keys/utils.go index 907f9eda807c..aa1b4bed9c07 100644 --- a/client/keys/utils.go +++ b/client/keys/utils.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/viper" - keys "github.com/cosmos/cosmos-sdk/crypto/keys" + "github.com/cosmos/cosmos-sdk/crypto/keys" "github.com/tendermint/tendermint/libs/cli" dbm "github.com/tendermint/tendermint/libs/db" @@ -173,3 +173,19 @@ func printInfos(infos []keys.Info) { func printKeyOutput(ko KeyOutput) { fmt.Printf("%s\t%s\t%s\t%s\n", ko.Name, ko.Type, ko.Address, ko.PubKey) } + +func printKeyAddress(info keys.Info) { + ko, err := Bech32KeyOutput(info) + if err != nil { + panic(err) + } + fmt.Println(ko.Address.String()) +} + +func printPubKey(info keys.Info) { + ko, err := Bech32KeyOutput(info) + if err != nil { + panic(err) + } + fmt.Println(ko.PubKey) +} diff --git a/client/tx/search.go b/client/tx/search.go index adad29d7dd9d..06b3c0972963 100644 --- a/client/tx/search.go +++ b/client/tx/search.go @@ -27,7 +27,20 @@ const ( func SearchTxCmd(cdc *wire.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "txs", - Short: "Search for all transactions that match the given tags", + Short: "Search for all transactions that match the given tags.", + Long: strings.TrimSpace(` +Search for transactions that match the given tags. By default, transactions must match ALL tags +passed to the --tags option. To match any transaction, use the --any option. + +For example: + +$ gaiacli tendermint txs --tag test1,test2 + +will match any transaction tagged with both test1,test2. To match a transaction tagged with either +test1 or test2, use: + +$ gaiacli tendermint txs --tag test1,test2 --any +`), RunE: func(cmd *cobra.Command, args []string) error { tags := viper.GetStringSlice(flagTags) @@ -52,7 +65,7 @@ func SearchTxCmd(cdc *wire.Codec) *cobra.Command { // TODO: change this to false once proofs built in cmd.Flags().Bool(client.FlagTrustNode, true, "Don't verify proofs for responses") - cmd.Flags().StringSlice(flagTags, nil, "Tags that must match (may provide multiple)") + cmd.Flags().StringSlice(flagTags, nil, "Comma-separated list of tags that must match") cmd.Flags().Bool(flagAny, false, "Return transactions that match ANY tag, rather than ALL") return cmd } diff --git a/server/tm_cmds.go b/server/tm_cmds.go index f852b4029ab6..c2395e3996eb 100644 --- a/server/tm_cmds.go +++ b/server/tm_cmds.go @@ -69,7 +69,7 @@ func ShowValidatorCmd(ctx *Context) *cobra.Command { func UnsafeResetAllCmd(ctx *Context) *cobra.Command { return &cobra.Command{ Use: "unsafe-reset-all", - Short: "Reset blockchain database, priv_validator.json file, and the logger", + Short: "Resets the blockchain database, removes address book files, and resets priv_validator.json to the genesis state", RunE: func(cmd *cobra.Command, args []string) error { cfg := ctx.Config tcmd.ResetAll(cfg.DBDir(), cfg.P2P.AddrBookFile(), cfg.PrivValidatorFile(), ctx.Logger)