Fix issue with geth account new#15529
Conversation
| return key, nil | ||
| } | ||
|
|
||
| func StoreKey(dir, auth string, scryptN, scryptP int) (error, common.Address) { |
There was a problem hiding this comment.
And reverse the return parameters. Error should always be the last return.
There was a problem hiding this comment.
Please use
func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) {
_, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP}, crand.Reader, passphrase)
return a.Address, err
}| } | ||
| fullpath := filepath.Join(dir, keyFileName(key.Address)) | ||
| err = writeKeyFile(fullpath, keyjson) | ||
| if err != nil { |
There was a problem hiding this comment.
A bit nicer would be if err = writeKeyFile(fullpath, keyjson); err != nil {
| // accountCreate creates a new account into the keystore defined by the CLI flags. | ||
| func accountCreate(ctx *cli.Context) error { | ||
| stack, _ := makeConfigNode(ctx) | ||
|
|
There was a problem hiding this comment.
Pls no empty line after a method header.
|
|
||
| func makeAccountManager(conf *Config) (*accounts.Manager, string, error) { | ||
| // ResolveAccountConfig determines the settings for scrypt and keydirectory | ||
| func ResolveAccountConfig(conf *Config) (int, int, string, error) { |
There was a problem hiding this comment.
Why not just make ResolveAccountConfig a method on Config? Also I'd rename to simply AccountConfig.
| } | ||
| } | ||
| return accounts.NewManager(backends...), ephemeral, nil | ||
| return accounts.NewManager(backends...), keydir, nil |
There was a problem hiding this comment.
Take care with this! The return parameter is the path only for ephemeral stores that the node will delete on shutting down!
| return key, nil | ||
| } | ||
|
|
||
| func StoreKey(dir, auth string, scryptN, scryptP int) (error, common.Address) { |
There was a problem hiding this comment.
Please use
func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) {
_, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP}, crand.Reader, passphrase)
return a.Address, err
}| func accountCreate(ctx *cli.Context) error { | ||
| stack, _ := makeConfigNode(ctx) | ||
|
|
||
| cfg := gethConfig{} |
There was a problem hiding this comment.
Please add Node: defaultNodeConfig(). That's the one that initializes the default datadir.
|
|
||
| if err != nil { | ||
| utils.Fatalf("Failed to create account: %v", err) | ||
| } |
There was a problem hiding this comment.
Sloppy paste error..
This PR makes
geth account newoperate directly on a keystore file, instead of using a complete keystore.The first commit should only involve the
geth account newcommand, whereas the second commit removes some code which is also used in other circumstances. As far as I could tell, it should be the same functionality, but theephemeralstring has been removed.