accounts/scwallet: Add a switch to enable smartcard support

This commit is contained in:
Guillaume Ballet 2019-04-10 12:19:49 +02:00
parent f0b878d56d
commit 0da1424e2f
7 changed files with 27 additions and 10 deletions

View file

@ -64,6 +64,7 @@ var (
utils.KeyStoreDirFlag,
utils.ExternalSignerFlag,
utils.NoUSBFlag,
utils.SmartCardFlag,
utils.DashboardEnabledFlag,
utils.DashboardAddrFlag,
utils.DashboardPortFlag,

View file

@ -71,6 +71,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.DataDirFlag,
utils.KeyStoreDirFlag,
utils.NoUSBFlag,
utils.SmartCardFlag,
utils.NetworkIdFlag,
utils.TestnetFlag,
utils.RinkebyFlag,

View file

@ -227,6 +227,7 @@ func getTestAccount(t *testing.T, dir string) (conf *node.Config, account accoun
DataDir: dir,
IPCPath: "bzzd.ipc",
NoUSB: true,
SmartCard: false,
}
n, err := node.New(conf)
if err != nil {

View file

@ -127,6 +127,10 @@ var (
Name: "nousb",
Usage: "Disables monitoring for and managing USB hardware wallets",
}
SmartCardFlag = cli.BoolTFlag{
Name: "smartcard",
Usage: "Enables support for smartcard",
}
NetworkIdFlag = cli.Uint64Flag{
Name: "networkid",
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)",
@ -1138,6 +1142,9 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
if ctx.GlobalIsSet(NoUSBFlag.Name) {
cfg.NoUSB = ctx.GlobalBool(NoUSBFlag.Name)
}
if ctx.GlobalIsSet(SmartCardFlag.Name) {
cfg.SmartCard = ctx.GlobalBoolT(SmartCardFlag.Name)
}
if ctx.GlobalIsSet(InsecureUnlockAllowedFlag.Name) {
cfg.InsecureUnlockAllowed = ctx.GlobalBool(InsecureUnlockAllowedFlag.Name)
}

View file

@ -95,6 +95,9 @@ type Config struct {
// NoUSB disables hardware wallet monitoring and connectivity.
NoUSB bool `toml:",omitempty"`
// SmartCard activates smartcard wallet monitoring and connectivity.
SmartCard 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
@ -505,6 +508,7 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) {
backends = append(backends, trezorhub)
}
}
if conf.SmartCard {
// Start a smart card hub
if schub, err := scwallet.NewHub(scwallet.Scheme, keydir); err != nil {
log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err))
@ -512,6 +516,7 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) {
backends = append(backends, schub)
}
}
}
return accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: conf.InsecureUnlockAllowed}, backends...), ephemeral, nil
}

View file

@ -114,6 +114,7 @@ func (e *ExecAdapter) NewNode(config *NodeConfig) (Node, error) {
conf.Stack.P2P.NoDiscovery = true
conf.Stack.P2P.NAT = nil
conf.Stack.NoUSB = true
conf.Stack.SmartCard = false
// listen on a localhost port, which we set when we
// initialise NodeConfig (usually a random port)

View file

@ -106,6 +106,7 @@ func (s *SimAdapter) NewNode(config *NodeConfig) (Node, error) {
EnableMsgEvents: config.EnableMsgEvents,
},
NoUSB: true,
SmartCard: false,
Logger: log.New("node.id", id.String()),
})
if err != nil {