diff --git a/CHANGELOG.md b/CHANGELOG.md index dd9b8bc2ee0e..0a1f29b0b6ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (client) [#14509](https://github.com/cosmos/cosmos-sdk/pull/#14509) Added `AddKeyringFlags` function. * (x/bank) [#14045](https://github.com/cosmos/cosmos-sdk/pull/14045) Add CLI command `spendable-balances`, which also accepts the flag `--denom`. * (x/slashing, x/staking) [#14363](https://github.com/cosmos/cosmos-sdk/pull/14363) Add the infraction a validator commited type as an argument to a `SlashWithInfractionReason` keeper method. * (client) [#14051](https://github.com/cosmos/cosmos-sdk/pull/14051) Add `--grpc` client option. @@ -72,6 +73,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (cli) [#14509](https://github.com/cosmos/cosmos-sdk/pull/#14509) Added missing options to keyring-backend flag usage * (server) [#14441](https://github.com/cosmos/cosmos-sdk/pull/14441) Fix `--log_format` flag not working. * (ante) [#14448](https://github.com/cosmos/cosmos-sdk/pull/14448) Return anteEvents when postHandler fail. diff --git a/client/flags/flags.go b/client/flags/flags.go index a0c408a61bd4..497ee383b983 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -5,6 +5,7 @@ import ( "strconv" "github.com/spf13/cobra" + "github.com/spf13/pflag" tmcli "github.com/tendermint/tendermint/libs/cli" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -106,34 +107,40 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) { // AddTxFlagsToCmd adds common flags to a module tx command. func AddTxFlagsToCmd(cmd *cobra.Command) { - cmd.Flags().StringP(FlagOutput, "o", "json", "Output format (text|json)") - cmd.Flags().String(FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used") - cmd.Flags().String(FlagFrom, "", "Name or address of private key with which to sign") - cmd.Flags().Uint64P(FlagAccountNumber, "a", 0, "The account number of the signing account (offline mode only)") - cmd.Flags().Uint64P(FlagSequence, "s", 0, "The sequence number of the signing account (offline mode only)") - cmd.Flags().String(FlagNote, "", "Note to add a description to the transaction (previously --memo)") - cmd.Flags().String(FlagFees, "", "Fees to pay along with transaction; eg: 10uatom") - cmd.Flags().String(FlagGasPrices, "", "Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)") - cmd.Flags().String(FlagNode, "tcp://localhost:26657", ": to tendermint rpc interface for this chain") - cmd.Flags().Bool(FlagUseLedger, false, "Use a connected Ledger device") - cmd.Flags().Float64(FlagGasAdjustment, DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ") - cmd.Flags().StringP(FlagBroadcastMode, "b", BroadcastSync, "Transaction broadcasting mode (sync|async)") - cmd.Flags().Bool(FlagDryRun, false, "ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible)") - cmd.Flags().Bool(FlagGenerateOnly, false, "Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)") - cmd.Flags().Bool(FlagOffline, false, "Offline mode (does not allow any online functionality)") - cmd.Flags().BoolP(FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation") - cmd.Flags().String(FlagKeyringBackend, DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test|memory)") - cmd.Flags().String(FlagSignMode, "", "Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature") - cmd.Flags().Uint64(FlagTimeoutHeight, 0, "Set a block timeout height to prevent the tx from being committed past a certain height") - cmd.Flags().String(FlagFeePayer, "", "Fee payer pays fees for the transaction instead of deducting from the signer") - cmd.Flags().String(FlagFeeGranter, "", "Fee granter grants fees for the transaction") - cmd.Flags().String(FlagTip, "", "Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator") - cmd.Flags().Bool(FlagAux, false, "Generate aux signer data instead of sending a tx") - cmd.Flags().String(FlagChainID, "", "The network chain ID") - + f := cmd.Flags() + f.StringP(FlagOutput, "o", "json", "Output format (text|json)") + f.String(FlagFrom, "", "Name or address of private key with which to sign") + f.Uint64P(FlagAccountNumber, "a", 0, "The account number of the signing account (offline mode only)") + f.Uint64P(FlagSequence, "s", 0, "The sequence number of the signing account (offline mode only)") + f.String(FlagNote, "", "Note to add a description to the transaction (previously --memo)") + f.String(FlagFees, "", "Fees to pay along with transaction; eg: 10uatom") + f.String(FlagGasPrices, "", "Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)") + f.String(FlagNode, "tcp://localhost:26657", ": to tendermint rpc interface for this chain") + f.Bool(FlagUseLedger, false, "Use a connected Ledger device") + f.Float64(FlagGasAdjustment, DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ") + f.StringP(FlagBroadcastMode, "b", BroadcastSync, "Transaction broadcasting mode (sync|async)") + f.Bool(FlagDryRun, false, "ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible)") + f.Bool(FlagGenerateOnly, false, "Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)") + f.Bool(FlagOffline, false, "Offline mode (does not allow any online functionality)") + f.BoolP(FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation") + f.String(FlagSignMode, "", "Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature") + f.Uint64(FlagTimeoutHeight, 0, "Set a block timeout height to prevent the tx from being committed past a certain height") + f.String(FlagFeePayer, "", "Fee payer pays fees for the transaction instead of deducting from the signer") + f.String(FlagFeeGranter, "", "Fee granter grants fees for the transaction") + f.String(FlagTip, "", "Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator") + f.Bool(FlagAux, false, "Generate aux signer data instead of sending a tx") + f.String(FlagChainID, "", "The network chain ID") // --gas can accept integers and "auto" - cmd.Flags().String(FlagGas, "", fmt.Sprintf("gas limit to set per-transaction; set to %q to calculate sufficient gas automatically. Note: %q option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of %q. (default %d)", + f.String(FlagGas, "", fmt.Sprintf("gas limit to set per-transaction; set to %q to calculate sufficient gas automatically. Note: %q option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of %q. (default %d)", GasFlagAuto, GasFlagAuto, FlagFees, DefaultGasLimit)) + + AddKeyringFlags(f) +} + +// AddKeyringFlags sets common keyring flags +func AddKeyringFlags(flags *pflag.FlagSet) { + flags.String(FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used") + flags.String(FlagKeyringBackend, DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test|memory)") } // AddPaginationFlagsToCmd adds common pagination flags to cmd diff --git a/client/keys/root.go b/client/keys/root.go index e8b1ef156987..93eb20ddd0c0 100644 --- a/client/keys/root.go +++ b/client/keys/root.go @@ -51,9 +51,8 @@ The pass backend requires GnuPG: https://gnupg.org/ ) cmd.PersistentFlags().String(flags.FlagHome, defaultNodeHome, "The application home directory") - cmd.PersistentFlags().String(flags.FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used") - cmd.PersistentFlags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") cmd.PersistentFlags().String(cli.OutputFlag, "text", "Output format (text|json)") + flags.AddKeyringFlags(cmd.PersistentFlags()) return cmd } diff --git a/docs/docs/run-node/00-keyring.md b/docs/docs/run-node/00-keyring.md index 46e0f772f746..2cb15b115cfd 100644 --- a/docs/docs/run-node/00-keyring.md +++ b/docs/docs/run-node/00-keyring.md @@ -106,6 +106,10 @@ The `memory` backend stores keys in memory. The keys are immediately deleted aft **Provided for testing purposes only. The `memory` backend is not recommended for use in production environments**. +### Setting backend using the env variable + +You can set the keyring-backend using env variable: `BINNAME_KEYRING_BACKEND`. For example, if you binary name is `gaia-v5` then set: `export GAIA_V5_KEYRING_BACKEND=pass` + ## Adding keys to the keyring :::warning