From de7454263d6490835549daeefa856c7ee10eb8ab Mon Sep 17 00:00:00 2001 From: lash Date: Wed, 24 Jan 2018 21:18:20 +0100 Subject: [PATCH] swarm: Add missing privatekey from swarm config w/o swap --- swarm/api/config.go | 10 ++++++++++ swarm/swarm.go | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/swarm/api/config.go b/swarm/api/config.go index 93b386cc11..14906176e9 100644 --- a/swarm/api/config.go +++ b/swarm/api/config.go @@ -63,6 +63,7 @@ type Config struct { Cors string BzzAccount string BootNodes string + privateKey *ecdsa.PrivateKey } //create a default config with all parameters to set to defaults @@ -113,5 +114,14 @@ func (self *Config) Init(prvKey *ecdsa.PrivateKey) { if self.SwapEnabled { self.Swap.Init(self.Contract, prvKey) } + self.privateKey = prvKey self.StoreParams.Init(self.Path) } + +func (self *Config) ShiftPrivateKey() (privKey *ecdsa.PrivateKey) { + if self.privateKey != nil { + privKey = self.privateKey + self.privateKey = nil + } + return privKey +} diff --git a/swarm/swarm.go b/swarm/swarm.go index c650567947..93c63eb68d 100644 --- a/swarm/swarm.go +++ b/swarm/swarm.go @@ -22,6 +22,7 @@ import ( "crypto/ecdsa" "fmt" "net" + "os" "path/filepath" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -93,7 +94,7 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, ensClient *e self = &Swarm{ config: config, backend: backend, - privateKey: config.Swap.PrivateKey(), + privateKey: config.ShiftPrivateKey(), } log.Debug(fmt.Sprintf("Setting up Swarm service components")) @@ -143,7 +144,8 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, ensClient *e } } - // set up high level api + // SET UP high level api + fmt.Fprintf(os.Stderr, "privkey %v\nswap %v\nswapendabled %v\n", self.privateKey, config.Swap, config.SwapEnabled) transactOpts := bind.NewKeyedTransactor(self.privateKey) if ensClient == nil {