Skip to content

Commit 75d62ef

Browse files
committed
cmd/utils: don't enumerate usb when --usb isn't set (ethereum#22130)
1 parent 1fa0757 commit 75d62ef

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

cmd/XDC/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ var (
6262
utils.BootnodesV5Flag,
6363
utils.DataDirFlag,
6464
utils.KeyStoreDirFlag,
65-
//utils.NoUSBFlag,
65+
utils.NoUSBFlag, // deprecated
66+
utils.USBFlag,
6667
utils.SmartCardDaemonPathFlag,
6768
//utils.EthashCacheDirFlag,
6869
//utils.EthashCachesInMemoryFlag,

cmd/utils/flags.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ var (
8888
Usage: "Directory for the keystore (default = inside the datadir)",
8989
Category: flags.AccountCategory,
9090
}
91+
USBFlag = &cli.BoolFlag{
92+
Name: "usb",
93+
Usage: "Enable monitoring and management of USB hardware wallets",
94+
Category: flags.AccountCategory,
95+
}
9196
SmartCardDaemonPathFlag = &cli.StringFlag{
9297
Name: "pcscdpath",
9398
Usage: "Path to the smartcard daemon (pcscd) socket file",
@@ -1220,8 +1225,11 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
12201225
if ctx.IsSet(LightKDFFlag.Name) {
12211226
cfg.UseLightweightKDF = ctx.Bool(LightKDFFlag.Name)
12221227
}
1223-
if ctx.IsSet(NoUSBFlag.Name) {
1224-
cfg.NoUSB = ctx.Bool(NoUSBFlag.Name)
1228+
if ctx.IsSet(NoUSBFlag.Name) || cfg.NoUSB {
1229+
log.Warn("Option nousb is deprecated and USB is deactivated by default. Use --usb to enable")
1230+
}
1231+
if ctx.IsSet(USBFlag.Name) {
1232+
cfg.USB = ctx.Bool(USBFlag.Name)
12251233
}
12261234
if ctx.IsSet(AnnounceTxsFlag.Name) {
12271235
cfg.AnnounceTxs = ctx.Bool(AnnounceTxsFlag.Name)

node/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ type Config struct {
8787
InsecureUnlockAllowed bool `toml:",omitempty"`
8888

8989
// NoUSB disables hardware wallet monitoring and connectivity.
90+
// Deprecated: USB monitoring is disabled by default and must be enabled explicitly.
9091
NoUSB bool `toml:",omitempty"`
9192

93+
// USB enables hardware wallet monitoring and connectivity.
94+
USB bool `toml:",omitempty"`
95+
9296
// SmartCardDaemonPath is the path to the smartcard daemon's socket.
9397
SmartCardDaemonPath string `toml:",omitempty"`
9498

p2p/simulations/adapters/docker.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ func (d *DockerAdapter) NewNode(config *NodeConfig) (Node, error) {
9393
conf.Stack.P2P.EnableMsgEvents = false
9494
conf.Stack.P2P.NoDiscovery = true
9595
conf.Stack.P2P.NAT = nil
96-
conf.Stack.NoUSB = true
9796
conf.Stack.Logger = log.New("node.id", config.ID.String())
9897

9998
node := &DockerNode{

p2p/simulations/adapters/exec.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ func (e *ExecAdapter) NewNode(config *NodeConfig) (Node, error) {
104104
conf.Stack.P2P.EnableMsgEvents = false
105105
conf.Stack.P2P.NoDiscovery = true
106106
conf.Stack.P2P.NAT = nil
107-
conf.Stack.NoUSB = true
108107

109108
// listen on a random localhost port (we'll get the actual port after
110109
// starting the node through the RPC admin.nodeInfo method)

p2p/simulations/adapters/inproc.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ func (sa *SimAdapter) NewNode(config *NodeConfig) (Node, error) {
8484
Dialer: sa,
8585
EnableMsgEvents: true,
8686
},
87-
NoUSB: true,
8887
Logger: log.New("node.id", id.String()),
8988
})
9089
if err != nil {

0 commit comments

Comments
 (0)