cmd/mist, cmd/ethereum: add CLI arguments for node key

This commit is contained in:
Felix Lange
2015-02-10 12:30:09 +01:00
parent 0c7df37351
commit a3cd218719
5 changed files with 72 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package eth
import (
"crypto/ecdsa"
"fmt"
"strings"
"sync"
@ -37,6 +38,10 @@ type Config struct {
// discovery node URLs.
BootNodes string
// This key is used to identify the node on the network.
// If nil, an ephemeral key is used.
NodeKey *ecdsa.PrivateKey
Shh bool
Dial bool
@ -150,9 +155,11 @@ func New(config *Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
netprv, err := crypto.GenerateKey()
if err != nil {
return nil, fmt.Errorf("could not generate server key: %v", err)
netprv := config.NodeKey
if netprv == nil {
if netprv, err = crypto.GenerateKey(); err != nil {
return nil, fmt.Errorf("could not generate server key: %v", err)
}
}
eth.net = &p2p.Server{
PrivateKey: netprv,