Skip to content

Commit

Permalink
fix: modify build eth fn definition for account unlock handling (ethe…
Browse files Browse the repository at this point in the history
  • Loading branch information
manav2401 committed May 23, 2022
1 parent 1b53044 commit 2323f2c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions internal/cli/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ func (c *Config) loadChain() error {
return nil
}

func (c *Config) buildEth(accountManager *accounts.Manager) (*ethconfig.Config, error) {
func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*ethconfig.Config, error) {
dbHandles, err := makeDatabaseHandles()
if err != nil {
return nil, err
Expand Down Expand Up @@ -670,15 +670,15 @@ func (c *Config) buildEth(accountManager *accounts.Manager) (*ethconfig.Config,
// unlock accounts
if len(c.Accounts.Unlock) > 0 {
if !stack.Config().InsecureUnlockAllowed && stack.Config().ExtRPCEnabled() {
return nil, fmt.Errorf("Account unlock with HTTP access is forbidden!")
return nil, fmt.Errorf("account unlock with HTTP access is forbidden")
}
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
ks := accountManager.Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
passwords, err := MakePasswordListFromFile(c.Accounts.PasswordFile)
if err != nil {
return nil, err
}
if len(passwords) < len(c.Accounts.Unlock) {
return nil, fmt.Errorf("Number of passwords provided (%v) is less than number of accounts (%v) to unlock",
return nil, fmt.Errorf("number of passwords provided (%v) is less than number of accounts (%v) to unlock",
len(passwords), len(c.Accounts.Unlock))
}
for i, account := range c.Accounts.Unlock {
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/server/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestConfigDefault(t *testing.T) {
_, err := config.buildNode()
assert.NoError(t, err)

_, err = config.buildEth(nil)
_, err = config.buildEth(nil, nil)
assert.NoError(t, err)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func NewServer(config *Config) (*Server, error) {
stack.AccountManager().AddBackend(keystore.NewKeyStore(keydir, n, p))

// register the ethereum backend
ethCfg, err := config.buildEth(stack.AccountManager())
ethCfg, err := config.buildEth(stack, stack.AccountManager())
if err != nil {
return nil, err
}
Expand All @@ -106,7 +106,7 @@ func NewServer(config *Config) (*Server, error) {
srv.backend = backend
} else {
// register the ethereum backend (with temporary created account manager)
ethCfg, err := config.buildEth(accountManager)
ethCfg, err := config.buildEth(stack, accountManager)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2323f2c

Please sign in to comment.