mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
cmd/geth: enhance account output
* enhance the format of the account list output to specify the fields (index, address, file) * also output the same format when creating a new account
This commit is contained in:
parent
38827dd9ca
commit
790fe879c2
2 changed files with 17 additions and 10 deletions
|
|
@ -98,7 +98,9 @@ And finally. DO NOT FORGET YOUR PASSWORD.
|
||||||
Usage: "Print account addresses",
|
Usage: "Print account addresses",
|
||||||
ArgsUsage: " ",
|
ArgsUsage: " ",
|
||||||
Description: `
|
Description: `
|
||||||
TODO: Please write this
|
geth account list
|
||||||
|
|
||||||
|
Lists every account with its index, address and path to the file.
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -181,7 +183,7 @@ nodes.
|
||||||
func accountList(ctx *cli.Context) error {
|
func accountList(ctx *cli.Context) error {
|
||||||
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
|
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
|
||||||
for i, acct := range stack.AccountManager().Accounts() {
|
for i, acct := range stack.AccountManager().Accounts() {
|
||||||
fmt.Printf("Account #%d: {%x} %s\n", i, acct.Address, acct.File)
|
fmt.Printf("Index: %d, Address: {%x}, File: %s\n", i, acct.Address, acct.File)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +281,8 @@ func accountCreate(ctx *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to create account: %v", err)
|
utils.Fatalf("Failed to create account: %v", err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Address: {%x}\n", account.Address)
|
index := len(stack.AccountManager().Accounts()) - 1
|
||||||
|
fmt.Printf("Index: %d, Address: {%x}, File: %s\n", index, account.Address, account.File)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,15 +53,15 @@ func TestAccountList(t *testing.T) {
|
||||||
defer geth.expectExit()
|
defer geth.expectExit()
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
geth.expect(`
|
geth.expect(`
|
||||||
Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} {{.Datadir}}\keystore\UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
|
Index: 0, Address: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8}, File: {{.Datadir}}\keystore\UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
|
||||||
Account #1: {f466859ead1932d743d622cb74fc058882e8648a} {{.Datadir}}\keystore\aaa
|
Index: 1, Address: {f466859ead1932d743d622cb74fc058882e8648a}, File: {{.Datadir}}\keystore\aaa
|
||||||
Account #2: {289d485d9771714cce91d3393d764e1311907acc} {{.Datadir}}\keystore\zzz
|
Index: 2, Address: {289d485d9771714cce91d3393d764e1311907acc}, File: {{.Datadir}}\keystore\zzz
|
||||||
`)
|
`)
|
||||||
} else {
|
} else {
|
||||||
geth.expect(`
|
geth.expect(`
|
||||||
Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} {{.Datadir}}/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
|
Index: 0, Address: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8}, File: {{.Datadir}}/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
|
||||||
Account #1: {f466859ead1932d743d622cb74fc058882e8648a} {{.Datadir}}/keystore/aaa
|
Index: 1, Address: {f466859ead1932d743d622cb74fc058882e8648a}, File: {{.Datadir}}/keystore/aaa
|
||||||
Account #2: {289d485d9771714cce91d3393d764e1311907acc} {{.Datadir}}/keystore/zzz
|
Index: 2, Address: {289d485d9771714cce91d3393d764e1311907acc}, File: {{.Datadir}}/keystore/zzz
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +75,11 @@ Your new account is locked with a password. Please give a password. Do not forge
|
||||||
Passphrase: {{.InputLine "foobar"}}
|
Passphrase: {{.InputLine "foobar"}}
|
||||||
Repeat passphrase: {{.InputLine "foobar"}}
|
Repeat passphrase: {{.InputLine "foobar"}}
|
||||||
`)
|
`)
|
||||||
geth.expectRegexp(`Address: \{[0-9a-f]{40}\}\n`)
|
if runtime.GOOS == "windows" {
|
||||||
|
geth.expectRegexp(`Index: [0-9], Address: \{[0-9a-f]{40}\}, File: (.*)\\keystore\\[0-9a-zA-z-.]{77}\n`)
|
||||||
|
} else {
|
||||||
|
geth.expectRegexp(`Index: [0-9], Address: \{[0-9a-f]{40}\}, File: (.*)/keystore/[0-9a-zA-z-.]{77}\n`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccountNewBadRepeat(t *testing.T) {
|
func TestAccountNewBadRepeat(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue