Accounts Revamp Fixes: "Overall" Wallet Improvements (#6736)

* change default wallet dir path to not be hidden

* gaz + pass wallet dir

* gaz + move const to flags

* move to flags

* move to flags

* use filepath join in order to create a valid dir name

* add wallet dir

* return err no wallet found issues

* fix up edit remote

* all tests passing

* fix test

* create or open wallet

* ivan feedback

* enter password for account with pubkey

* Update validator/accounts/v2/accounts_create.go

Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com>

* works

* preston feedback

* nothing to export

* fmt

* test for create or open

* gaz

Co-authored-by: shayzluf <thezluf@gmail.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com>
This commit is contained in:
Raul Jordan
2020-07-28 20:20:13 -05:00
committed by GitHub
parent 1a1c1bb813
commit 9d08ba49de
25 changed files with 381 additions and 265 deletions

View File

@@ -20,8 +20,10 @@ go_library(
"//shared/petnames:go_default_library",
"//shared/roughtime:go_default_library",
"//validator/accounts/v2/iface:go_default_library",
"//validator/flags:go_default_library",
"//validator/keymanager/v2:go_default_library",
"@com_github_google_uuid//:go_default_library",
"@com_github_logrusorgru_aurora//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",

View File

@@ -9,9 +9,11 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"sync"
"github.com/google/uuid"
"github.com/logrusorgru/aurora"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-ssz"
validatorpb "github.com/prysmaticlabs/prysm/proto/validator/accounts/v2"
@@ -21,6 +23,7 @@ import (
"github.com/prysmaticlabs/prysm/shared/petnames"
"github.com/prysmaticlabs/prysm/shared/roughtime"
"github.com/prysmaticlabs/prysm/validator/accounts/v2/iface"
"github.com/prysmaticlabs/prysm/validator/flags"
v2keymanager "github.com/prysmaticlabs/prysm/validator/keymanager/v2"
"github.com/sirupsen/logrus"
keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4"
@@ -47,7 +50,8 @@ const (
// Config for a direct keymanager.
type Config struct {
EIPVersion string `json:"direct_eip_version"`
EIPVersion string `json:"direct_eip_version"`
AccountPasswordsDirectory string `json:"direct_accounts_passwords_directory"`
}
// Keymanager implementation for direct keystores utilizing EIP-2335.
@@ -61,7 +65,8 @@ type Keymanager struct {
// DefaultConfig for a direct keymanager implementation.
func DefaultConfig() *Config {
return &Config{
EIPVersion: eipVersion,
EIPVersion: eipVersion,
AccountPasswordsDirectory: flags.WalletPasswordsDirFlag.Value,
}
}
@@ -106,6 +111,30 @@ func MarshalConfigFile(ctx context.Context, cfg *Config) ([]byte, error) {
return json.MarshalIndent(cfg, "", "\t")
}
// Config for the direct keymanager.
func (dr *Keymanager) Config() *Config {
return dr.cfg
}
// String pretty-print of a direct keymanager configuration.
func (c *Config) String() string {
au := aurora.NewAurora(true)
var b strings.Builder
strAddr := fmt.Sprintf("%s: %s\n", au.BrightMagenta("EIP Version"), c.EIPVersion)
if _, err := b.WriteString(strAddr); err != nil {
log.Error(err)
return ""
}
strCrt := fmt.Sprintf(
"%s: %s\n", au.BrightMagenta("Accounts Passwords Directory"), c.AccountPasswordsDirectory,
)
if _, err := b.WriteString(strCrt); err != nil {
log.Error(err)
return ""
}
return b.String()
}
// ValidatingAccountNames for a direct keymanager.
func (dr *Keymanager) ValidatingAccountNames() ([]string, error) {
return dr.wallet.ListDirs()