accounts, cmd/geth, internal: tiny polishes

This commit is contained in:
Péter Szilágyi 2019-04-04 13:10:44 +03:00
parent a3f494d977
commit 41a3c112fe
No known key found for this signature in database
GPG key ID: E9AE538CEDF8293D
3 changed files with 7 additions and 4 deletions

View file

@ -24,6 +24,10 @@ import (
"github.com/ethereum/go-ethereum/event"
)
// Config contains the settings of the global account manager.
//
// TODO(rjl493456442, karalabe, holiman): Get rid of this when account management
// is removed in favor of Clef.
type Config struct {
InsecureUnlockAllowed bool // Whether account unlocking in insecure environment is allowed
}
@ -31,7 +35,7 @@ type Config struct {
// Manager is an overarching account manager that can communicate with various
// backends for signing transactions.
type Manager struct {
config *Config // Account manager relative configs
config *Config // Global account manager configurations
backends map[reflect.Type][]Backend // Index of backends currently registered
updaters []event.Subscription // Wallet update subscriptions for all backends
updates chan WalletEvent // Subscription sink for backend wallet changes

View file

@ -411,8 +411,7 @@ func unlockAccounts(ctx *cli.Context, stack *node.Node) {
// If insecure account unlocking is not allowed if node's APIs are exposed to external.
// Print warning log to user and skip unlocking.
if !stack.Config().InsecureUnlockAllowed && stack.Config().ExtRPCEnabled() {
log.Warn("Not safe to unlock account, please enable `allow-insecure-unlock` flag if necessary")
return
utils.Fatalf("Account unlock with HTTP access is forbidden!")
}
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
passwords := utils.MakePasswordList(ctx)

View file

@ -322,7 +322,7 @@ func (s *PrivateAccountAPI) UnlockAccount(ctx context.Context, addr common.Addre
// explicitly specifies to allow the insecure account unlocking, otherwise
// it is disabled.
if s.b.ExtRPCEnabled() && !s.b.AccountManager().Config().InsecureUnlockAllowed {
return false, errors.New("not safe to unlock account, please enable `allow-insecure-unlock` flag if necessary")
return false, errors.New("account unlock with HTTP access is forbidden")
}
const max = uint64(time.Duration(math.MaxInt64) / time.Second)