mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Merge 76f36a4c67 into 6f607de5d5
This commit is contained in:
commit
720f9f8b04
1 changed files with 34 additions and 10 deletions
|
|
@ -161,15 +161,14 @@ Clef that the file is 'safe' to execute.`,
|
|||
Action: utils.MigrateFlags(addCredential),
|
||||
Name: "addpw",
|
||||
Usage: "Store a credential for a keystore file",
|
||||
ArgsUsage: "<address> <password>",
|
||||
ArgsUsage: "<address>",
|
||||
Flags: []cli.Flag{
|
||||
logLevelFlag,
|
||||
configdirFlag,
|
||||
signerSecretFlag,
|
||||
},
|
||||
Description: `
|
||||
The addpw command stores a password for a given address (keyfile). If you invoke it with only one parameter, it will
|
||||
remove any stored credential for that address (keyfile)
|
||||
The addpw command stores a password for a given address (keyfile).
|
||||
`,
|
||||
}
|
||||
)
|
||||
|
|
@ -203,6 +202,7 @@ func init() {
|
|||
app.Commands = []cli.Command{initCommand, attestCommand, addCredentialCommand}
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
|
|
@ -210,6 +210,29 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
// promptPassword retrieves the password entered interactively
|
||||
// from the user.
|
||||
func promptPassword(prompt string, confirmation bool) string {
|
||||
// Prompt the user for the password
|
||||
if prompt != "" {
|
||||
fmt.Println(prompt)
|
||||
}
|
||||
password, err := console.Stdin.PromptPassword("Password: ")
|
||||
if err != nil {
|
||||
utils.Fatalf("Failed to read password: %v", err)
|
||||
}
|
||||
if confirmation {
|
||||
confirm, err := console.Stdin.PromptPassword("Repeat password: ")
|
||||
if err != nil {
|
||||
utils.Fatalf("Failed to read password confirmation: %v", err)
|
||||
}
|
||||
if password != confirm {
|
||||
utils.Fatalf("Passwords do not match")
|
||||
}
|
||||
}
|
||||
return password
|
||||
}
|
||||
|
||||
func initializeSecrets(c *cli.Context) error {
|
||||
if err := initialize(c); err != nil {
|
||||
return err
|
||||
|
|
@ -269,6 +292,7 @@ NOTE: This file does not contain your accounts. Those need to be backed up separ
|
|||
`)
|
||||
return nil
|
||||
}
|
||||
|
||||
func attestFile(ctx *cli.Context) error {
|
||||
if len(ctx.Args()) < 1 {
|
||||
utils.Fatalf("This command requires an argument.")
|
||||
|
|
@ -295,8 +319,12 @@ func attestFile(ctx *cli.Context) error {
|
|||
|
||||
func addCredential(ctx *cli.Context) error {
|
||||
if len(ctx.Args()) < 1 {
|
||||
utils.Fatalf("This command requires at leaste one argument.")
|
||||
utils.Fatalf("This command requires at least one argument.")
|
||||
}
|
||||
|
||||
// Prompt user to enter a password
|
||||
password := promptPassword("Enter a password to store with this address.", true)
|
||||
|
||||
if err := initialize(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -312,11 +340,7 @@ func addCredential(ctx *cli.Context) error {
|
|||
// Initialize the encrypted storages
|
||||
pwStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "credentials.json"), pwkey)
|
||||
key := ctx.Args().First()
|
||||
value := ""
|
||||
if len(ctx.Args()) > 1 {
|
||||
value = ctx.Args().Get(1)
|
||||
}
|
||||
pwStorage.Put(key, value)
|
||||
pwStorage.Put(key, password)
|
||||
log.Info("Credential store updated", "key", key)
|
||||
return nil
|
||||
}
|
||||
|
|
@ -734,4 +758,4 @@ curl -i -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","me
|
|||
curl -i -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"account_sign","params":["0x694267f14675d7e1b9494fd8d72fefe1755710fa","bazonk gaz baz"],"id":67}' http://localhost:8550/
|
||||
|
||||
|
||||
**/
|
||||
**/
|
||||
Loading…
Reference in a new issue