cosmos-sdk/x/slashing/client/cli/tx.go

39 lines
1012 B
Go
Raw Normal View History

2018-05-31 18:02:10 -07:00
package cli
import (
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/slashing"
)
// create unrevoke command
func GetCmdUnrevoke(cdc *wire.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "unrevoke",
Args: cobra.ExactArgs(1),
Short: "unrevoke validator previously revoked for downtime",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.NewCoreContextFromViper().WithDecoder(authcmd.GetAccountDecoder(cdc))
2018-06-01 12:32:26 -07:00
validatorAddr, err := sdk.GetAccAddressBech32(args[0])
2018-05-31 18:02:10 -07:00
if err != nil {
return err
}
msg := slashing.NewMsgUnrevoke(validatorAddr)
// build and sign the transaction, then broadcast to Tendermint
2018-07-05 22:19:50 -07:00
err = ctx.EnsureSignBuildBroadcast(ctx.FromAddressName, []sdk.Msg{msg}, cdc)
2018-05-31 18:02:10 -07:00
if err != nil {
return err
}
return nil
},
}
return cmd
}