Encaptulate Get Passphrase Logic in Builder

This commit is contained in:
Yukai Tu
2018-03-24 23:14:18 -07:00
parent 2d45058352
commit 96d9c55172
6 changed files with 21 additions and 48 deletions
+2 -18
View File
@@ -36,16 +36,8 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
// get account name
name := viper.GetString(client.FlagName)
// get password
buf := client.BufferStdin()
prompt := fmt.Sprintf("Password to sign with '%s':", name)
passphrase, err := client.GetPassword(prompt, buf)
if err != nil {
return err
}
// build and sign the transaction, then broadcast to Tendermint
res, err := builder.SignBuildBroadcast(name, passphrase, msg, cdc)
res, err := builder.SignBuildBroadcast(name, msg, cdc)
if err != nil {
return err
}
@@ -75,19 +67,11 @@ func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command {
// get account name
name := viper.GetString(client.FlagName)
// get password
buf := client.BufferStdin()
prompt := fmt.Sprintf("Password to sign with '%s':", name)
passphrase, err := client.GetPassword(prompt, buf)
if err != nil {
return err
}
// create the message
msg := cool.NewSetTrendMsg(from, args[0])
// build and sign the transaction, then broadcast to Tendermint
res, err := builder.SignBuildBroadcast(name, passphrase, msg, cdc)
res, err := builder.SignBuildBroadcast(name, msg, cdc)
if err != nil {
return err
}