diff options
Diffstat (limited to 'eth')
-rw-r--r-- | eth/backend.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/eth/backend.go b/eth/backend.go index f5ebc9033..e8555061d 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -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, |