Browse Source

gen_node_key cmd

pull/1439/head
Anton Kaliaev 7 years ago
parent
commit
c954fca376
No known key found for this signature in database GPG Key ID: 7B6881D965918214
2 changed files with 33 additions and 0 deletions
  1. +32
    -0
      cmd/tendermint/commands/gen_node_key.go
  2. +1
    -0
      cmd/tendermint/main.go

+ 32
- 0
cmd/tendermint/commands/gen_node_key.go View File

@ -0,0 +1,32 @@
package commands
import (
"fmt"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/p2p"
cmn "github.com/tendermint/tmlibs/common"
)
// GenNodeKeyCmd allows the generation of a node key. It prints node's ID to
// the standard output.
var GenNodeKeyCmd = &cobra.Command{
Use: "gen_node_key",
Short: "Generate a node key for this node and print its ID",
RunE: genNodeKey,
}
func genNodeKey(cmd *cobra.Command, args []string) error {
nodeKeyFile := config.NodeKeyFile()
if cmn.FileExists(nodeKeyFile) {
return fmt.Errorf("node key at %s already exists", nodeKeyFile)
}
nodeKey, err := p2p.LoadOrGenNodeKey(nodeKeyFile)
if err != nil {
return err
}
fmt.Println(nodeKey.ID())
return nil
}

+ 1
- 0
cmd/tendermint/main.go View File

@ -25,6 +25,7 @@ func main() {
cmd.ShowValidatorCmd,
cmd.TestnetFilesCmd,
cmd.ShowNodeIDCmd,
cmd.GenNodeKeyCmd,
cmd.VersionCmd)
// NOTE:


Loading…
Cancel
Save