Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accounts, cmd, internal, signer: add note about backing up the keystore #19432

Merged
merged 5 commits into from
May 7, 2019

Conversation

kurkomisi
Copy link
Contributor

@kurkomisi kurkomisi commented Apr 10, 2019

Fixes #19165

Running geth account new:

Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase: 
Repeat passphrase: 
Your new key was generated
Address: {adbb1348ab38e354ca79f7284701d701d02b351c}
Please backup your key file!
Path:    {/home/user/.ethereum/keystore/UTC--2019-04-25T11-07-21.800464724Z--adbb1348ab38e354ca79f7284701d701d02b351c}
Please remember your password!

In geth console running personal.newAccount():

Passphrase: 
Repeat passphrase: 
INFO [04-25|13:53:24.946] Your new key was generated               address=0xbD8603B63EaC7633987e1F331D542a5e99dA4418
WARN [04-25|13:53:24.946] Please backup your key file!             path=/home/user/.ethereum/rinkeby/keystore/UTC--2019-04-25T10-53-23.649181805Z--bd8603b63eac7633987e1f331d542a5e99da4418
WARN [04-25|13:53:24.946] Please remember your password! 
"0xbd8603b63eac7633987e1f331d542a5e99da4418"

clef:

curl -H "Content-Type: application/json" -X POST --data "{\"jsonrpc\":\"2.0\",\"method\":\"account_new\", \"id\":67}" http://localhost:8550/
-------- New Account request--------------

A request has been made to create a new account. 
Approving this operation means that a new account is created,
and the address is returned to the external caller

Request context:
	127.0.0.1:58370 -> HTTP/1.1 -> localhost:8550

Additional HTTP header data, provided by the external caller:
	User-Agent: curl/7.58.0
	Origin: 
Approve? [y/N]:
> y
## New account password

Please enter a password for the new account to be created (attempt 0 of 3)
> -----------------------
INFO [04-25|13:59:59.010] Your new key was generated               address=0xD84f83cdf440061b7259dCb1EC39b83B747836C6
WARN [04-25|13:59:59.010] Please backup your key file!             path=/home/user/.ethereum/keystore/UTC--2019-04-25T10-59-57.750166407Z--d84f83cdf440061b7259dcb1ec39b83b747836c6
WARN [04-25|13:59:59.010] Please remember your password!

@@ -179,6 +179,8 @@ func storeNewKey(ks keyStore, rand io.Reader, auth string) (*Key, accounts.Accou
zeroKey(key.PrivateKey)
return nil, a, err
}
fmt.Printf("Your new key is generated. Please backup the key file: %s\n", a.URL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used from other locations aswell, we shouldn't fmt.Printf from within a lower library. If you modify StoreKey instead, which is only called from accountCreate, then you can pick out the URL from the returned account, and either do the printout there, or -- better, return the entire account instead of just the address

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I returned the entire account instead of just the address.

@kurkomisi kurkomisi force-pushed the keystore-backup-message branch 2 times, most recently from 7529fb7 to 0e076a0 Compare April 10, 2019 09:22
@kurkomisi kurkomisi changed the title accounts: add note about backing up the keystore accounts, cmd: add note about backing up the keystore Apr 10, 2019
@holiman
Copy link
Contributor

holiman commented Apr 10, 2019

Looks good. Now please add a log info message for server side when new account is created via rpc aswell

@kurkomisi kurkomisi force-pushed the keystore-backup-message branch from 0e076a0 to 7d79fa1 Compare April 15, 2019 12:06
@kurkomisi kurkomisi requested a review from karalabe as a code owner April 15, 2019 12:06
@kurkomisi kurkomisi changed the title accounts, cmd: add note about backing up the keystore accounts, cmd, internal, signer: add note about backing up the keystore Apr 15, 2019
@kurkomisi kurkomisi requested a review from holiman April 15, 2019 12:30
@kurkomisi kurkomisi added this to the 1.9.0 milestone Apr 25, 2019
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -295,6 +295,7 @@ func (s *PrivateAccountAPI) DeriveAccount(url string, path string, pin *bool) (a
func (s *PrivateAccountAPI) NewAccount(password string) (common.Address, error) {
acc, err := fetchKeystore(s.am).NewAccount(password)
if err == nil {
log.Info("Your new key is generated. Please backup the key file", "path", acc.URL.Path)
Copy link
Member

@karalabe karalabe Apr 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, logs should be shorter than 40 character to keep them aligned. Perhaps let's split there into 3? cc @holiman ?

log.Info("Your new key was generated", "address", /* dunno what goes here */)
log.Warn("Please backup your key file!", "path", acc.URL.Path)
log.Warn("Please remember your password!")

Warn makes sure it's a bit more visible. Open for opposition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do go down this path, do it for the other occurrences too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sounds good

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@karalabe
Copy link
Member

karalabe commented May 7, 2019

@kurkomisi Fix the tests please, and run the test suite next time before opening a PR.

@holiman
Copy link
Contributor

holiman commented May 7, 2019

--- FAIL: TestAccountNew (0.20s)
	test_cmd.go:250: (stderr) INFO [04-25|11:15:51.118] Bumping default cache on mainnet         provided=1024 updated=4096
	test_cmd.go:250: (stderr) WARN [04-25|11:15:51.118] Sanitizing cache to Go's GC limits       provided=4096 updated=2490
	test_cmd.go:250: (stderr) INFO [04-25|11:15:51.120] Maximum peer count                       ETH=25 LES=0 total=25
	test_cmd.go:114: Matched stdout text:
		Your new account is locked with a password. Please give a password. Do not forget this password.
		!! Unsupported terminal, password will be echoed.
		Passphrase: 
		Repeat passphrase: 
	test_cmd.go:162: Matched stdout text:
		Your new key was generated
		Address: {42c3a86b03684333096b6ceee843e89e4a317bba}
		Ple
	test_cmd.go:183: Unmatched stdout text:
		ase backup your key file!
		Path:    {/tmp/geth-test847508519/keystore/UTC--2019-04-25T11-15-51.121447117Z--42c3a86b03684333096b6ceee843e89e4a317bba}
		Please remember your password!

@karalabe karalabe merged commit 107c67d into ethereum:master May 7, 2019
@finleyexp
Copy link

finleyexp commented Feb 9, 2021

How do you backup the keystore file? Every where I go it says "backup keystore" but nowhere does it say "use these steps to backup keystore". I've looked in the Geth tuts:

https://geth.ethereum.org/docs/interface/mining
https://geth.ethereum.org/docs/interface/command-line-options
https://ethereum.org/en/developers/tutorials/run-light-node-geth/

gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 2, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 3, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 4, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 6, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 7, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 7, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 7, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 9, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 10, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 10, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 14, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 16, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 17, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 22, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 22, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 23, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cmd/geth: add note about backing up the keystore
5 participants