2018-05-31 18:02:10 -07:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
2018-08-06 11:11:30 -07:00
|
|
|
"os"
|
2018-05-31 18:02:10 -07:00
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
2018-08-06 11:11:30 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
2018-05-31 18:02:10 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/wire"
|
|
|
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
2018-09-07 10:04:58 -07:00
|
|
|
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
|
2018-05-31 18:02:10 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/slashing"
|
2018-08-06 11:11:30 -07:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2018-05-31 18:02:10 -07:00
|
|
|
)
|
|
|
|
|
2018-08-22 08:56:13 -07:00
|
|
|
// GetCmdUnjail implements the create unjail validator command.
|
|
|
|
func GetCmdUnjail(cdc *wire.Codec) *cobra.Command {
|
2018-05-31 18:02:10 -07:00
|
|
|
cmd := &cobra.Command{
|
2018-08-22 08:56:13 -07:00
|
|
|
Use: "unjail",
|
2018-08-28 09:59:42 -07:00
|
|
|
Args: cobra.NoArgs,
|
2018-08-22 08:56:13 -07:00
|
|
|
Short: "unjail validator previously jailed for downtime",
|
2018-05-31 18:02:10 -07:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2018-09-07 10:15:49 -07:00
|
|
|
txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
|
2018-08-06 11:11:30 -07:00
|
|
|
cliCtx := context.NewCLIContext().
|
|
|
|
WithCodec(cdc).
|
|
|
|
WithLogger(os.Stdout).
|
|
|
|
WithAccountDecoder(authcmd.GetAccountDecoder(cdc))
|
2018-05-31 18:02:10 -07:00
|
|
|
|
2018-08-30 21:06:44 -07:00
|
|
|
valAddr, err := cliCtx.GetFromAddress()
|
2018-05-31 18:02:10 -07:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-08-30 21:06:44 -07:00
|
|
|
msg := slashing.NewMsgUnjail(sdk.ValAddress(valAddr))
|
2018-09-02 11:20:14 -07:00
|
|
|
if cliCtx.GenerateOnly {
|
2018-09-07 10:15:49 -07:00
|
|
|
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
|
2018-09-02 11:20:14 -07:00
|
|
|
}
|
2018-09-07 10:15:49 -07:00
|
|
|
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
2018-05-31 18:02:10 -07:00
|
|
|
},
|
|
|
|
}
|
2018-08-06 11:11:30 -07:00
|
|
|
|
2018-05-31 18:02:10 -07:00
|
|
|
return cmd
|
|
|
|
}
|