mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 13:44:31 +00:00
accounts, cmd: add note about backing up the keystore (#19432)
This commit is contained in:
parent
44b6b14685
commit
fa35614784
3 changed files with 24 additions and 5 deletions
|
|
@ -37,6 +37,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/accounts"
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/common/math"
|
||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||
|
|
@ -96,9 +97,9 @@ func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string)
|
|||
}
|
||||
|
||||
// StoreKey generates a key, encrypts with 'auth' and stores in the given directory
|
||||
func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) {
|
||||
func StoreKey(dir, auth string, scryptN, scryptP int) (accounts.Account, error) {
|
||||
_, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP, false}, rand.Reader, auth)
|
||||
return a.Address, err
|
||||
return a, err
|
||||
}
|
||||
|
||||
func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) error {
|
||||
|
|
|
|||
|
|
@ -310,12 +310,18 @@ func accountCreate(ctx *cli.Context) error {
|
|||
|
||||
password := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx))
|
||||
|
||||
address, err := keystore.StoreKey(keydir, password, scryptN, scryptP)
|
||||
account, err := keystore.StoreKey(keydir, password, scryptN, scryptP)
|
||||
|
||||
if err != nil {
|
||||
utils.Fatalf("Failed to create account: %v", err)
|
||||
}
|
||||
fmt.Printf("Address: {xdc%x}\n", address)
|
||||
fmt.Printf("\nYour new key was generated\n\n")
|
||||
fmt.Printf("Public address of the key: %s\n", account.Address.Hex())
|
||||
fmt.Printf("Path of the secret key file: %s\n\n", account.URL.Path)
|
||||
fmt.Printf("- You can share your public address with anyone. Others need it to interact with you.\n")
|
||||
fmt.Printf("- You must NEVER share the secret key with anyone! The key controls access to your funds!\n")
|
||||
fmt.Printf("- You must BACKUP your key file! Without the key, it's impossible to access account funds!\n")
|
||||
fmt.Printf("- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!\n\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,20 @@ Your new account is locked with a password. Please give a password. Do not forge
|
|||
!! Unsupported terminal, password will be echoed.
|
||||
Passphrase: {{.InputLine "foobar"}}
|
||||
Repeat passphrase: {{.InputLine "foobar"}}
|
||||
|
||||
Your new key was generated
|
||||
|
||||
`)
|
||||
XDC.ExpectRegexp(`
|
||||
Public address of the key: xdc[0-9a-fA-F]{40}
|
||||
Path of the secret key file: .*UTC--.+--xdc[0-9a-fA-F]{40}
|
||||
|
||||
- You can share your public address with anyone. Others need it to interact with you.
|
||||
- You must NEVER share the secret key with anyone! The key controls access to your funds!
|
||||
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
|
||||
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!
|
||||
|
||||
`)
|
||||
XDC.ExpectRegexp(`Address: \{xdc[0-9a-f]{40}\}\n`)
|
||||
}
|
||||
|
||||
func TestAccountNewBadRepeat(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue