From 6430e672c99f6d22582b104f8467d4bd8a4b5f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 20 Apr 2017 14:01:51 +0300 Subject: cmd, node: add --nosub and node.Config.NoUSB to disable hw wallets --- cmd/geth/main.go | 1 + cmd/geth/usage.go | 1 + cmd/utils/flags.go | 7 +++++++ node/config.go | 13 +++++++++---- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index c2d719d95..ad7b639a3 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -88,6 +88,7 @@ func init() { utils.BootnodesFlag, utils.DataDirFlag, utils.KeyStoreDirFlag, + utils.NoUSBFlag, utils.EthashCacheDirFlag, utils.EthashCachesInMemoryFlag, utils.EthashCachesOnDiskFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 457728154..9f06a308b 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -67,6 +67,7 @@ var AppHelpFlagGroups = []flagGroup{ configFileFlag, utils.DataDirFlag, utils.KeyStoreDirFlag, + utils.NoUSBFlag, utils.NetworkIdFlag, utils.TestNetFlag, utils.DevModeFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index b35574c86..af9585bd0 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -115,6 +115,10 @@ var ( Name: "keystore", Usage: "Directory for the keystore (default = inside the datadir)", } + NoUSBFlag = cli.BoolFlag{ + Name: "nousb", + Usage: "Disables monitoring for and managine USB hardware wallets", + } EthashCacheDirFlag = DirectoryFlag{ Name: "ethash.cachedir", Usage: "Directory to store the ethash verification caches (default = inside the datadir)", @@ -729,6 +733,9 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { if ctx.GlobalIsSet(LightKDFFlag.Name) { cfg.UseLightweightKDF = ctx.GlobalBool(LightKDFFlag.Name) } + if ctx.GlobalIsSet(NoUSBFlag.Name) { + cfg.NoUSB = ctx.GlobalBool(NoUSBFlag.Name) + } } func setGPO(ctx *cli.Context, cfg *gasprice.Config) { diff --git a/node/config.go b/node/config.go index 1bab4c574..61e0008ef 100644 --- a/node/config.go +++ b/node/config.go @@ -82,6 +82,9 @@ type Config struct { // scrypt KDF at the expense of security. UseLightweightKDF bool `toml:",omitempty"` + // NoUSB disables hardware wallet monitoring and connectivity. + NoUSB bool `toml:",omitempty"` + // IPCPath is the requested location to place the IPC endpoint. If the path is // a simple file name, it is placed inside the data directory (or on the root // pipe path on Windows), whereas if it's a resolvable path name (absolute or @@ -389,10 +392,12 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) { backends := []accounts.Backend{ keystore.NewKeyStore(keydir, scryptN, scryptP), } - if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil { - log.Warn(fmt.Sprintf("Failed to start Ledger hub, disabling: %v", err)) - } else { - backends = append(backends, ledgerhub) + if !conf.NoUSB { + if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil { + log.Warn(fmt.Sprintf("Failed to start Ledger hub, disabling: %v", err)) + } else { + backends = append(backends, ledgerhub) + } } return accounts.NewManager(backends...), ephemeral, nil } -- cgit v1.2.3