mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 10:20:44 +00:00
accounts/scwallet: add a switch to specify path to sc daemon (#19439)
This commit is contained in:
parent
fb35c54280
commit
100ea1c8e0
3 changed files with 61 additions and 14 deletions
|
|
@ -63,6 +63,7 @@ var (
|
||||||
utils.DataDirFlag,
|
utils.DataDirFlag,
|
||||||
utils.KeyStoreDirFlag,
|
utils.KeyStoreDirFlag,
|
||||||
//utils.NoUSBFlag,
|
//utils.NoUSBFlag,
|
||||||
|
utils.SmartCardDaemonPathFlag,
|
||||||
//utils.EthashCacheDirFlag,
|
//utils.EthashCacheDirFlag,
|
||||||
//utils.EthashCachesInMemoryFlag,
|
//utils.EthashCachesInMemoryFlag,
|
||||||
//utils.EthashCachesOnDiskFlag,
|
//utils.EthashCachesOnDiskFlag,
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ import (
|
||||||
"github.com/XinFinOrg/XDPoSChain/p2p/netutil"
|
"github.com/XinFinOrg/XDPoSChain/p2p/netutil"
|
||||||
"github.com/XinFinOrg/XDPoSChain/params"
|
"github.com/XinFinOrg/XDPoSChain/params"
|
||||||
"github.com/XinFinOrg/XDPoSChain/rpc"
|
"github.com/XinFinOrg/XDPoSChain/rpc"
|
||||||
|
pcsclite "github.com/gballet/go-libpcsclite"
|
||||||
gopsutil "github.com/shirou/gopsutil/mem"
|
gopsutil "github.com/shirou/gopsutil/mem"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
@ -87,6 +88,12 @@ var (
|
||||||
Usage: "Directory for the keystore (default = inside the datadir)",
|
Usage: "Directory for the keystore (default = inside the datadir)",
|
||||||
Category: flags.AccountCategory,
|
Category: flags.AccountCategory,
|
||||||
}
|
}
|
||||||
|
SmartCardDaemonPathFlag = &cli.StringFlag{
|
||||||
|
Name: "pcscdpath",
|
||||||
|
Usage: "Path to the smartcard daemon (pcscd) socket file",
|
||||||
|
Value: pcsclite.PCSCDSockName,
|
||||||
|
Category: flags.AccountCategory,
|
||||||
|
}
|
||||||
NetworkIdFlag = &cli.Uint64Flag{
|
NetworkIdFlag = &cli.Uint64Flag{
|
||||||
Name: "networkid",
|
Name: "networkid",
|
||||||
Usage: "Network identifier (integer, 89=XDPoSChain)",
|
Usage: "Network identifier (integer, 89=XDPoSChain)",
|
||||||
|
|
@ -1194,6 +1201,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
|
||||||
setWS(ctx, cfg)
|
setWS(ctx, cfg)
|
||||||
setNodeUserIdent(ctx, cfg)
|
setNodeUserIdent(ctx, cfg)
|
||||||
setPrefix(ctx, cfg)
|
setPrefix(ctx, cfg)
|
||||||
|
setSmartCard(ctx, cfg)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case ctx.IsSet(DataDirFlag.Name):
|
case ctx.IsSet(DataDirFlag.Name):
|
||||||
|
|
@ -1227,6 +1235,26 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setSmartCard(ctx *cli.Context, cfg *node.Config) {
|
||||||
|
// Skip enabling smartcards if no path is set
|
||||||
|
path := ctx.String(SmartCardDaemonPathFlag.Name)
|
||||||
|
if path == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Sanity check that the smartcard path is valid
|
||||||
|
fi, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Info("Smartcard socket not found, disabling", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if fi.Mode()&os.ModeType != os.ModeSocket {
|
||||||
|
log.Error("Invalid smartcard daemon path", "path", path, "type", fi.Mode().String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Smartcard daemon path exists and is a socket, enable it
|
||||||
|
cfg.SmartCardDaemonPath = path
|
||||||
|
}
|
||||||
|
|
||||||
func setGPO(ctx *cli.Context, cfg *gasprice.Config, light bool) {
|
func setGPO(ctx *cli.Context, cfg *gasprice.Config, light bool) {
|
||||||
// If we are running the light client, apply another group
|
// If we are running the light client, apply another group
|
||||||
// settings for gas oracle.
|
// settings for gas oracle.
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/accounts"
|
"github.com/XinFinOrg/XDPoSChain/accounts"
|
||||||
"github.com/XinFinOrg/XDPoSChain/accounts/keystore"
|
"github.com/XinFinOrg/XDPoSChain/accounts/keystore"
|
||||||
|
"github.com/XinFinOrg/XDPoSChain/accounts/scwallet"
|
||||||
"github.com/XinFinOrg/XDPoSChain/accounts/usbwallet"
|
"github.com/XinFinOrg/XDPoSChain/accounts/usbwallet"
|
||||||
"github.com/XinFinOrg/XDPoSChain/common"
|
"github.com/XinFinOrg/XDPoSChain/common"
|
||||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||||
|
|
@ -88,6 +89,9 @@ type Config struct {
|
||||||
// NoUSB disables hardware wallet monitoring and connectivity.
|
// NoUSB disables hardware wallet monitoring and connectivity.
|
||||||
NoUSB bool `toml:",omitempty"`
|
NoUSB bool `toml:",omitempty"`
|
||||||
|
|
||||||
|
// SmartCardDaemonPath is the path to the smartcard daemon's socket.
|
||||||
|
SmartCardDaemonPath string `toml:",omitempty"`
|
||||||
|
|
||||||
// IPCPath is the requested location to place the IPC endpoint. If the path is
|
// 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
|
// 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
|
// pipe path on Windows), whereas if it's a resolvable path name (absolute or
|
||||||
|
|
@ -425,22 +429,36 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
// Assemble the account manager and supported backends
|
// Assemble the account manager and supported backends
|
||||||
backends := []accounts.Backend{
|
var backends []accounts.Backend
|
||||||
keystore.NewKeyStore(keydir, scryptN, scryptP),
|
if len(backends) == 0 {
|
||||||
}
|
// For now, we're using EITHER external signer OR local signers.
|
||||||
if !conf.NoUSB {
|
// If/when we implement some form of lockfile for USB and keystore wallets,
|
||||||
// Start a USB hub for Ledger hardware wallets
|
// we can have both, but it's very confusing for the user to see the same
|
||||||
if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil {
|
// accounts in both externally and locally, plus very racey.
|
||||||
log.Warn(fmt.Sprintf("Failed to start Ledger hub, disabling: %v", err))
|
backends = append(backends, keystore.NewKeyStore(keydir, scryptN, scryptP))
|
||||||
} else {
|
if !conf.NoUSB {
|
||||||
backends = append(backends, ledgerhub)
|
// Start a USB hub for Ledger hardware wallets
|
||||||
|
if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil {
|
||||||
|
log.Warn(fmt.Sprintf("Failed to start Ledger hub, disabling: %v", err))
|
||||||
|
} else {
|
||||||
|
backends = append(backends, ledgerhub)
|
||||||
|
}
|
||||||
|
// Start a USB hub for Trezor hardware wallets
|
||||||
|
if trezorhub, err := usbwallet.NewTrezorHub(); err != nil {
|
||||||
|
log.Warn(fmt.Sprintf("Failed to start Trezor hub, disabling: %v", err))
|
||||||
|
} else {
|
||||||
|
backends = append(backends, trezorhub)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Start a USB hub for Trezor hardware wallets
|
if len(conf.SmartCardDaemonPath) > 0 {
|
||||||
if trezorhub, err := usbwallet.NewTrezorHub(); err != nil {
|
// Start a smart card hub
|
||||||
log.Warn(fmt.Sprintf("Failed to start Trezor hub, disabling: %v", err))
|
if schub, err := scwallet.NewHub(conf.SmartCardDaemonPath, scwallet.Scheme, keydir); err != nil {
|
||||||
} else {
|
log.Warn(fmt.Sprintf("Failed to start smart card hub, disabling: %v", err))
|
||||||
backends = append(backends, trezorhub)
|
} else {
|
||||||
|
backends = append(backends, schub)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: conf.InsecureUnlockAllowed}, backends...), ephemeral, nil
|
return accounts.NewManager(&accounts.Config{InsecureUnlockAllowed: conf.InsecureUnlockAllowed}, backends...), ephemeral, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue