Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ var nodeIP string
var nodeInfoCmd = &cobra.Command{
Use: "info",
Short: "Get node information",
Long: `Get node ID and BLS public key from an avalanchego node.`,
Long: `Get node ID and BLS public key from an avalanchego node.

Accepts --ip (IP or IP:port) or the global --rpc-url flag.
When both are provided, --ip takes precedence.`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx, cancel := getOperationContext()
defer cancel()

if nodeIP == "" {
return fmt.Errorf("--ip is required")
addr := nodeIP
if addr == "" && customRPCURL != "" {
addr = customRPCURL
}
if addr == "" {
return fmt.Errorf("--ip or --rpc-url is required")
}

info, err := node.GetNodeInfoWithInsecureHTTP(ctx, nodeIP, allowInsecureHTTP)
info, err := node.GetNodeInfoWithInsecureHTTP(ctx, addr, allowInsecureHTTP)
if err != nil {
return fmt.Errorf("failed to get node info: %w", err)
}
Expand All @@ -43,5 +50,5 @@ func init() {
rootCmd.AddCommand(nodeCmd)
nodeCmd.AddCommand(nodeInfoCmd)

nodeInfoCmd.Flags().StringVar(&nodeIP, "ip", "", "Node IP address")
nodeInfoCmd.Flags().StringVar(&nodeIP, "ip", "", "Node IP or IP:port (also accepts --rpc-url)")
}
Loading