cmd/utils: don't enumerate usb when --usb isn't set (#22130)

This commit is contained in:
Daniel Liu 2025-01-14 10:56:12 +08:00
parent 83b7c0eacb
commit e33909649b
6 changed files with 16 additions and 6 deletions

View file

@ -62,7 +62,8 @@ var (
utils.BootnodesV5Flag,
utils.DataDirFlag,
utils.KeyStoreDirFlag,
//utils.NoUSBFlag,
utils.NoUSBFlag, // deprecated
utils.USBFlag,
utils.SmartCardDaemonPathFlag,
//utils.EthashCacheDirFlag,
//utils.EthashCachesInMemoryFlag,

View file

@ -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",
@ -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)

View file

@ -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"`

View file

@ -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{

View file

@ -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)

View file

@ -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 {