forked from dymensionxyz/dymint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added command to show the p2p node id. (dymensionxyz#186)
- Loading branch information
1 parent
2174584
commit d2e6d13
Showing
2 changed files
with
39 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,38 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/dymensionxyz/dymint/conv" | ||
"github.com/libp2p/go-libp2p" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/tendermint/tendermint/p2p" | ||
) | ||
|
||
// ShowNodeIDCmd dumps node's ID to the standard output. | ||
var ShowNodeIDCmd = &cobra.Command{ | ||
Use: "show-node-id", | ||
Aliases: []string{"show_node_id"}, | ||
Short: "Show this node's ID", | ||
RunE: showNodeID, | ||
} | ||
|
||
func showNodeID(cmd *cobra.Command, args []string) error { | ||
nodeKey, err := p2p.LoadNodeKey(tmconfig.NodeKeyFile()) | ||
if err != nil { | ||
return err | ||
} | ||
signingKey, err := conv.GetNodeKey(nodeKey) | ||
if err != nil { | ||
return err | ||
} | ||
// convert nodeKey to libp2p key | ||
host, err := libp2p.New(libp2p.Identity(signingKey)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Println(host.ID()) | ||
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