swarm: use privateKey from Swarm value

This commit is contained in:
Anton Evangelatov 2018-03-05 19:59:33 +01:00
parent 97cb1a2aa6
commit d9ae59f38d

View file

@ -183,7 +183,7 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
opts := []api.MultiResolverOption{} opts := []api.MultiResolverOption{}
for _, c := range config.EnsAPIs { for _, c := range config.EnsAPIs {
tld, endpoint, addr := parseEnsAPIAddress(c) tld, endpoint, addr := parseEnsAPIAddress(c)
r, err := newEnsClient(endpoint, addr, config) r, err := newEnsClient(endpoint, addr, config, self.privateKey)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -252,7 +252,7 @@ type ensClient struct {
// newEnsClient creates a new ENS client for that is a consumer of // newEnsClient creates a new ENS client for that is a consumer of
// a ENS API on a specific endpoint. It is used as a helper function // a ENS API on a specific endpoint. It is used as a helper function
// for creating multiple resolvers in NewSwarm function. // for creating multiple resolvers in NewSwarm function.
func newEnsClient(endpoint string, addr common.Address, config *api.Config) (*ensClient, error) { func newEnsClient(endpoint string, addr common.Address, config *api.Config, privkey *ecdsa.PrivateKey) (*ensClient, error) {
log.Info("connecting to ENS API", "url", endpoint) log.Info("connecting to ENS API", "url", endpoint)
client, err := rpc.Dial(endpoint) client, err := rpc.Dial(endpoint)
if err != nil { if err != nil {
@ -271,7 +271,7 @@ func newEnsClient(endpoint string, addr common.Address, config *api.Config) (*en
log.Warn(fmt.Sprintf("could not determine ENS contract address, using default %s", ensRoot), "err", err) log.Warn(fmt.Sprintf("could not determine ENS contract address, using default %s", ensRoot), "err", err)
} }
} }
transactOpts := bind.NewKeyedTransactor(config.Swap.PrivateKey()) transactOpts := bind.NewKeyedTransactor(privkey)
dns, err := ens.NewENS(transactOpts, ensRoot, ethClient) dns, err := ens.NewENS(transactOpts, ensRoot, ethClient)
if err != nil { if err != nil {
return nil, err return nil, err