diff --git a/tools/enr-calculator/main.go b/tools/enr-calculator/main.go index 6f04ff3678..68dad04dfa 100644 --- a/tools/enr-calculator/main.go +++ b/tools/enr-calculator/main.go @@ -5,6 +5,7 @@ package main import ( "crypto/ecdsa" "flag" + "io/ioutil" "net" "github.com/btcsuite/btcd/btcec" @@ -19,6 +20,7 @@ var ( privateKey = flag.String("private", "", "Base-64 encoded Private key to use for calculation of ENR") port = flag.Int("port", 0, "Port to use for calculation of ENR") ipAddr = flag.String("ipAddress", "", "IP to use in calculation of ENR") + outfile = flag.String("out", "", "Filepath to write ENR") ) func main() { @@ -61,4 +63,12 @@ func main() { localNode.Set(ipEntry) localNode.Set(udpEntry) log.Info(localNode.Node().String()) + + if *outfile != "" { + err := ioutil.WriteFile(*outfile, []byte(localNode.Node().String()), 0644) + if err != nil { + panic(err) + } + log.Infof("Wrote to %s", *outfile) + } }