Skip to content

Commit

Permalink
Added show-sequencer command to print the sequencer pubkey. (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
omritoptix authored Jan 10, 2023
1 parent 2fb8663 commit d808ecb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions cmd/dymint/commands/show_sequencer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package commands

import (
"fmt"

"github.com/spf13/cobra"
tmjson "github.com/tendermint/tendermint/libs/json"
tmos "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/privval"
)

// ShowSequencer adds capabilities for showing the validator info.
var ShowSequencer = &cobra.Command{
Use: "show-sequencer",
Aliases: []string{"show_sequencer"},
Short: "Show this node's sequencer info",
RunE: showSequencer,
// PreRun: deprecateSnakeCase,
}

func showSequencer(cmd *cobra.Command, args []string) error {
keyFilePath := tmconfig.PrivValidatorKeyFile()
if !tmos.FileExists(keyFilePath) {
return fmt.Errorf("sequencer file %s does not exist", keyFilePath)
}

pv := privval.LoadFilePV(keyFilePath, tmconfig.PrivValidatorStateFile())

pubKey, err := pv.GetPubKey()
if err != nil {
return fmt.Errorf("can't get pubkey: %w", err)
}

bz, err := tmjson.Marshal(pubKey)
if err != nil {
return fmt.Errorf("failed to marshal sequencer pubkey: %w", err)
}

fmt.Println(string(bz))
return nil
}
1 change: 1 addition & 0 deletions cmd/dymint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func main() {
rootCmd := commands.RootCmd
rootCmd.AddCommand(
commands.InitFilesCmd,
commands.ShowSequencer,
debug.DebugCmd,
cli.NewCompletionCmd(rootCmd, true),
)
Expand Down

0 comments on commit d808ecb

Please sign in to comment.