Skip to content

Commit

Permalink
cmd/utils: don't enumerate usb when --usb isn't set (ethereum#22130)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Jan 17, 2025
1 parent 07e5200 commit a4c4095
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cmd/XDC/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ var (
utils.BootnodesV5Flag,
utils.DataDirFlag,
utils.KeyStoreDirFlag,
//utils.NoUSBFlag,
utils.NoUSBFlag, // deprecated
utils.USBFlag,
utils.SmartCardDaemonPathFlag,
//utils.EthashCacheDirFlag,
//utils.EthashCachesInMemoryFlag,
Expand Down
12 changes: 10 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ var (
Usage: "Directory for the keystore (default = inside the datadir)",
Category: flags.AccountCategory,
}
USBFlag = &cli.BoolFlag{
Name: "usb",
Usage: "Enable monitoring and management of USB hardware wallets",
Category: flags.AccountCategory,
}
SmartCardDaemonPathFlag = &cli.StringFlag{
Name: "pcscdpath",
Usage: "Path to the smartcard daemon (pcscd) socket file",
Expand Down Expand Up @@ -1220,8 +1225,11 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
if ctx.IsSet(LightKDFFlag.Name) {
cfg.UseLightweightKDF = ctx.Bool(LightKDFFlag.Name)
}
if ctx.IsSet(NoUSBFlag.Name) {
cfg.NoUSB = ctx.Bool(NoUSBFlag.Name)
if ctx.IsSet(NoUSBFlag.Name) || cfg.NoUSB {
log.Warn("Option nousb is deprecated and USB is deactivated by default. Use --usb to enable")
}
if ctx.IsSet(USBFlag.Name) {
cfg.USB = ctx.Bool(USBFlag.Name)
}
if ctx.IsSet(AnnounceTxsFlag.Name) {
cfg.AnnounceTxs = ctx.Bool(AnnounceTxsFlag.Name)
Expand Down
4 changes: 4 additions & 0 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ type Config struct {
InsecureUnlockAllowed bool `toml:",omitempty"`

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

// USB enables hardware wallet monitoring and connectivity.
USB bool `toml:",omitempty"`

// SmartCardDaemonPath is the path to the smartcard daemon's socket.
SmartCardDaemonPath string `toml:",omitempty"`

Expand Down
1 change: 0 additions & 1 deletion p2p/simulations/adapters/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func (d *DockerAdapter) NewNode(config *NodeConfig) (Node, error) {
conf.Stack.P2P.EnableMsgEvents = false
conf.Stack.P2P.NoDiscovery = true
conf.Stack.P2P.NAT = nil
conf.Stack.NoUSB = true
conf.Stack.Logger = log.New("node.id", config.ID.String())

node := &DockerNode{
Expand Down
1 change: 0 additions & 1 deletion p2p/simulations/adapters/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (e *ExecAdapter) NewNode(config *NodeConfig) (Node, error) {
conf.Stack.P2P.EnableMsgEvents = false
conf.Stack.P2P.NoDiscovery = true
conf.Stack.P2P.NAT = nil
conf.Stack.NoUSB = true

// listen on a random localhost port (we'll get the actual port after
// starting the node through the RPC admin.nodeInfo method)
Expand Down
1 change: 0 additions & 1 deletion p2p/simulations/adapters/inproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func (sa *SimAdapter) NewNode(config *NodeConfig) (Node, error) {
Dialer: sa,
EnableMsgEvents: true,
},
NoUSB: true,
Logger: log.New("node.id", id.String()),
})
if err != nil {
Expand Down

0 comments on commit a4c4095

Please sign in to comment.