mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
fix: modify build eth fn definition for account unlock handling (#412)
This commit is contained in:
parent
1b53044055
commit
2323f2c96e
3 changed files with 7 additions and 7 deletions
|
|
@ -615,7 +615,7 @@ func (c *Config) loadChain() error {
|
||||||
return nil
|
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()
|
dbHandles, err := makeDatabaseHandles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -670,15 +670,15 @@ func (c *Config) buildEth(accountManager *accounts.Manager) (*ethconfig.Config,
|
||||||
// unlock accounts
|
// unlock accounts
|
||||||
if len(c.Accounts.Unlock) > 0 {
|
if len(c.Accounts.Unlock) > 0 {
|
||||||
if !stack.Config().InsecureUnlockAllowed && stack.Config().ExtRPCEnabled() {
|
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)
|
passwords, err := MakePasswordListFromFile(c.Accounts.PasswordFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(passwords) < len(c.Accounts.Unlock) {
|
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))
|
len(passwords), len(c.Accounts.Unlock))
|
||||||
}
|
}
|
||||||
for i, account := range c.Accounts.Unlock {
|
for i, account := range c.Accounts.Unlock {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ func TestConfigDefault(t *testing.T) {
|
||||||
_, err := config.buildNode()
|
_, err := config.buildNode()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
_, err = config.buildEth(nil)
|
_, err = config.buildEth(nil, nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ func NewServer(config *Config) (*Server, error) {
|
||||||
stack.AccountManager().AddBackend(keystore.NewKeyStore(keydir, n, p))
|
stack.AccountManager().AddBackend(keystore.NewKeyStore(keydir, n, p))
|
||||||
|
|
||||||
// register the ethereum backend
|
// register the ethereum backend
|
||||||
ethCfg, err := config.buildEth(stack.AccountManager())
|
ethCfg, err := config.buildEth(stack, stack.AccountManager())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +106,7 @@ func NewServer(config *Config) (*Server, error) {
|
||||||
srv.backend = backend
|
srv.backend = backend
|
||||||
} else {
|
} else {
|
||||||
// register the ethereum backend (with temporary created account manager)
|
// register the ethereum backend (with temporary created account manager)
|
||||||
ethCfg, err := config.buildEth(accountManager)
|
ethCfg, err := config.buildEth(stack, accountManager)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue