From ecc17e56cba55e7d29907ff629a8e3ed9c8bfe33 Mon Sep 17 00:00:00 2001 From: wangzhiyong Date: Mon, 24 Dec 2018 12:33:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=8Av0.0.9=20changelog=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++ client/keys/cmd.go | 2 - client/keys/mnemonic.go | 41 ----------- client/keys/new.go | 147 ---------------------------------------- server/init.go | 6 +- version/version.go | 2 +- 6 files changed, 9 insertions(+), 195 deletions(-) delete mode 100644 client/keys/mnemonic.go delete mode 100644 client/keys/new.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 204610d..ccf0022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.0.9 +2018.12.24 + +**IMPROVEMENTS** +* [client] 客户端部分命令修改 + ## v0.0.8 2018.12.21 diff --git a/client/keys/cmd.go b/client/keys/cmd.go index be969d0..0a2c6e7 100644 --- a/client/keys/cmd.go +++ b/client/keys/cmd.go @@ -17,8 +17,6 @@ func KeysCommand(cdc *go_amino.Codec) *cobra.Command { needs to sign with a private key.`, } cmd.AddCommand( - mnemonicKeyCommand(), - newKeyCommand(cdc), addKeyCommand(cdc), listKeysCmd(cdc), types.LineBreak, diff --git a/client/keys/mnemonic.go b/client/keys/mnemonic.go deleted file mode 100644 index 1f742e9..0000000 --- a/client/keys/mnemonic.go +++ /dev/null @@ -1,41 +0,0 @@ -package keys - -import ( - "fmt" - - "github.com/spf13/cobra" - "github.com/tyler-smith/go-bip39" -) - -const ( - mnemonicEntropySize = 256 -) - -func mnemonicKeyCommand() *cobra.Command { - cmd := &cobra.Command{ - Use: "mnemonic", - Short: "Compute the bip39 mnemonic", - Long: "Create a bip39 mnemonic, sometimes called a seed phrase, by reading from the system entropy.", - RunE: runMnemonicCmd, - } - return cmd -} - -func runMnemonicCmd(cmd *cobra.Command, args []string) error { - - var entropySeed []byte - var err error - entropySeed, err = bip39.NewEntropy(mnemonicEntropySize) - if err != nil { - return err - } - - mnemonic, err := bip39.NewMnemonic(entropySeed[:]) - if err != nil { - return err - } - - fmt.Println(mnemonic) - - return nil -} diff --git a/client/keys/new.go b/client/keys/new.go deleted file mode 100644 index 8e45cd1..0000000 --- a/client/keys/new.go +++ /dev/null @@ -1,147 +0,0 @@ -package keys - -import ( - "fmt" - - "github.com/QOSGroup/qbase/client/context" - "github.com/QOSGroup/qbase/client/utils" - "github.com/QOSGroup/qbase/keys/hd" - "github.com/spf13/cobra" - - go_amino "github.com/tendermint/go-amino" - "github.com/tyler-smith/go-bip39" -) - -const ( - flagNewDefault = "default" - flagBIP44Path = "bip44-path" -) - -func newKeyCommand(cdc *go_amino.Codec) *cobra.Command { - cmd := &cobra.Command{ - Use: "new", - Short: "Interactive command to derive a new private key, encrypt it, and save to disk", - Long: `Derive a new private key using an interactive command that will prompt you for each input. -Optionally specify a bip39 mnemonic, a bip39 passphrase to further secure the mnemonic, -and a bip32 HD path to derive a specific account. The key will be stored under the given name -and encrypted with the given password. The only input that is required is the encryption password.`, - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - cliCtx := context.NewCLIContext().WithCodec(cdc) - return runNewCmd(cliCtx, cmd, args) - }, - } - cmd.Flags().Bool(flagNewDefault, false, "Skip the prompts and just use the default values for everything") - cmd.Flags().String(flagBIP44Path, "44'/118'/0'/0/0", "BIP44 path from which to derive a private key") - return cmd -} - -/* -input - - bip44 path - - bip39 mnemonic - - local encryption password -output - - armor encrypted private key (saved to file) -*/ -func runNewCmd(ctx context.CLIContext, cmd *cobra.Command, args []string) error { - name := args[0] - kb, err := GetKeyBase(ctx) - if err != nil { - return err - } - - buf := utils.BufferStdin() - - _, err = kb.Get(name) - if err == nil { - // account exists, ask for user confirmation - if response, err := utils.GetConfirmation( - fmt.Sprintf("> override the existing name %s", name), buf); err != nil || !response { - return err - } - } - - flags := cmd.Flags() - useDefaults, _ := flags.GetBool(flagNewDefault) - bipFlag := flags.Lookup(flagBIP44Path) - - bip44Params, err := getBIP44ParamsAndPath(bipFlag.Value.String(), bipFlag.Changed || useDefaults) - if err != nil { - return err - } - - var mnemonic string - - if !useDefaults { - mnemonic, err = utils.GetString("Enter your bip39 mnemonic, or hit enter to generate one.", buf) - if err != nil { - return err - } - } - - if len(mnemonic) == 0 { - // read entropy seed straight from crypto.Rand and convert to mnemonic - entropySeed, err := bip39.NewEntropy(mnemonicEntropySize) - if err != nil { - return err - } - - mnemonic, err = bip39.NewMnemonic(entropySeed[:]) - if err != nil { - return err - } - } - - // get the encryption password - encryptPassword, err := utils.GetCheckPassword( - "> Enter a passphrase to encrypt your key to disk(password must be at least 8 characters):", - "> Repeat the passphrase:", buf) - if err != nil { - return err - } - - info, err := kb.Derive(name, mnemonic, encryptPassword, bip44Params.String()) - if err != nil { - return err - } - - _ = info - return nil -} - -func getBIP44ParamsAndPath(path string, flagSet bool) (*hd.BIP44Params, error) { - buf := utils.BufferStdin() - bip44Path := path - - // if it wasn't set in the flag, give it a chance to overide interactively - if !flagSet { - var err error - - printStep() - - bip44Path, err = utils.GetString(fmt.Sprintf("Enter your bip44 path. Default is %s\n", path), buf) - if err != nil { - return nil, err - } - - if len(bip44Path) == 0 { - bip44Path = path - } - } - - bip44params, err := hd.NewParamsFromPath(bip44Path) - if err != nil { - return nil, err - } - - return bip44params, nil -} - -func printPrefixed(msg string) { - fmt.Printf("> %s\n", msg) -} - -func printStep() { - printPrefixed("-------------------------------------") -} diff --git a/server/init.go b/server/init.go index 16b912b..2a08230 100644 --- a/server/init.go +++ b/server/init.go @@ -192,10 +192,8 @@ func InitCmd(ctx *Context, cdc *Codec, appInit AppInit) *cobra.Command { } cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file") cmd.Flags().String(FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") - cmd.Flags().Bool(FlagWithTxs, false, "apply existing genesis transactions from [--home]/config/gentx/") - cmd.Flags().AddFlagSet(appInit.FlagsAppGenState) - cmd.Flags().AddFlagSet(appInit.FlagsAppGenTx) // need to add this flagset for when no GenTx's provided - cmd.AddCommand(GenTxCmd(ctx, cdc, appInit)) + cmd.Flags().String(FlagName, "", "a custom human readable name for this node. required") + cmd.MarkFlagRequired(FlagName) return cmd } diff --git a/version/version.go b/version/version.go index b71700f..8649b55 100644 --- a/version/version.go +++ b/version/version.go @@ -2,4 +2,4 @@ package version // GitCommit set by build flags -var Version = "0.0.8" +var Version = "0.0.9"