swarm: Add missing privatekey from swarm config w/o swap

This commit is contained in:
lash 2018-01-24 21:18:20 +01:00
parent 8d7bf3f3ef
commit de7454263d
2 changed files with 14 additions and 2 deletions

View file

@ -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
}

View file

@ -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 {