go-ethereum/cmd/bootnode/main.go
Marius van der Wijden f3bc3a0ca2 cmd/bootnode: nuke bootnode functionality
Since we're not supporting creating custom networks anymore,
it makes little sense to still have the bootnode utility,
except for creating the nodekey
2024-11-26 12:11:34 +01:00

49 lines
1.4 KiB
Go

// Copyright 2015 The go-ethereum Authors
// This file is part of go-ethereum.
//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// bootnode runs a bootstrap node for the Ethereum Discovery Protocol.
package main
import (
"crypto/ecdsa"
"flag"
"fmt"
"net"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/p2p/enode"
)
func main() {
var (
genKey = flag.String("genkey", "", "generate a node key")
nodeKey *ecdsa.PrivateKey
err error
)
flag.Parse()
if *genKey != "" {
nodeKey, err = crypto.GenerateKey()
if err != nil {
utils.Fatalf("could not generate key: %v", err)
}
if err = crypto.SaveECDSA(*genKey, nodeKey); err != nil {
utils.Fatalf("%v", err)
}
n := enode.NewV4(&nodeKey.PublicKey, net.IP{127, 0, 0, 1}, 0, 30303)
fmt.Println(n.URLv4())
}
}