@@ -42,6 +42,9 @@ import (
4242var (
4343 inputNodeKeyProtocol * string
4444 inputNodeKeyType * string
45+ inputNodeKeyIP * string
46+ inputNodeKeyTCP * int
47+ inputNodeKeyUDP * int
4548)
4649
4750// nodekeyCmd represents the nodekey command
@@ -74,14 +77,14 @@ func generateETHNodeKey() error {
7477 if err != nil {
7578 return fmt .Errorf ("could not generate key: %v" , err )
7679 }
80+
7781 ko := nodeKeyOut {}
78- ko .PublicKey = fmt .Sprintf ("%x\n " , gethcrypto .FromECDSAPub (& nodeKey .PublicKey )[1 :])
82+ ko .PublicKey = fmt .Sprintf ("%x" , gethcrypto .FromECDSAPub (& nodeKey .PublicKey )[1 :])
7983 prvKeyBytes := gethcrypto .FromECDSA (nodeKey )
8084 ko .PrivateKey = hex .EncodeToString (prvKeyBytes )
8185
82- // err = gethcrypto.SaveECDSA("/dev/stdout", nodeKey)
83- ip := net .IPv4 (0 , 0 , 0 , 0 )
84- n := gethenode .NewV4 (& nodeKey .PublicKey , ip , 30303 , 303030 )
86+ ip := net .ParseIP (* inputNodeKeyIP )
87+ n := gethenode .NewV4 (& nodeKey .PublicKey , ip , * inputNodeKeyTCP , * inputNodeKeyUDP )
8588
8689 ko .ENR = n .String ()
8790
@@ -99,6 +102,9 @@ func init() {
99102
100103 inputNodeKeyProtocol = nodekeyCmd .PersistentFlags ().String ("protocol" , "devp2p" , "devp2p|libp2p|pex" )
101104 inputNodeKeyType = nodekeyCmd .PersistentFlags ().String ("key-type" , "ed25519" , "The type of key" )
105+ inputNodeKeyIP = nodekeyCmd .PersistentFlags ().StringP ("ip" , "i" , "0.0.0.0" , "The IP to be associated with this address" )
106+ inputNodeKeyTCP = nodekeyCmd .PersistentFlags ().IntP ("tcp" , "t" , 30303 , "The tcp Port to be associated with this address" )
107+ inputNodeKeyUDP = nodekeyCmd .PersistentFlags ().IntP ("udp" , "u" , 0 , "The udp Port to be associated with this address" )
102108
103109 // Here you will define your flags and configuration settings.
104110
0 commit comments