github.com/devwanda/aphelion-staking@v0.33.9/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/devwanda/aphelion-staking/p2p"
     9  )
    10  
    11  // ShowNodeIDCmd dumps node's ID to the standard output.
    12  var ShowNodeIDCmd = &cobra.Command{
    13  	Use:   "show_node_id",
    14  	Short: "Show this node's ID",
    15  	RunE:  showNodeID,
    16  }
    17  
    18  func showNodeID(cmd *cobra.Command, args []string) error {
    19  	nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile())
    20  	if err != nil {
    21  		return err
    22  	}
    23  
    24  	fmt.Println(nodeKey.ID())
    25  	return nil
    26  }