-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added show-sequencer command to print the sequencer pubkey. (#178)
- Loading branch information
1 parent
2fb8663
commit d808ecb
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters