github.com/vipernet-xyz/tm@v0.34.24/cmd/tendermint/commands/show_node_id.go (about)

     1  package commands
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/spf13/cobra"
     7  
     8  	"github.com/vipernet-xyz/tm/p2p"
     9  )
    10  
    11  // ShowNodeIDCmd dumps node's ID to the standard output.
    12  var ShowNodeIDCmd = &cobra.Command{
    13  	Use:     "show-node-id",
    14  	Aliases: []string{"show_node_id"},
    15  	Short:   "Show this node's ID",
    16  	RunE:    showNodeID,
    17  	PreRun:  deprecateSnakeCase,
    18  }
    19  
    20  func showNodeID(cmd *cobra.Command, args []string) error {
    21  	nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile())
    22  	if err != nil {
    23  		return err
    24  	}
    25  
    26  	fmt.Println(nodeKey.ID())
    27  	return nil
    28  }