mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
ErrInvalidPubKey; machine-readable account list output
This commit is contained in:
parent
f2ab351e8d
commit
bb824a8557
2 changed files with 20 additions and 4 deletions
|
|
@ -527,11 +527,24 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||
func accountList(ctx *cli.Context) {
|
||||
accman := utils.MakeAccountManager(ctx)
|
||||
accts, err := accman.Accounts()
|
||||
arg := ctx.Args().First()
|
||||
if err != nil {
|
||||
utils.Fatalf("Could not list accounts: %v", err)
|
||||
}
|
||||
for i, acct := range accts {
|
||||
fmt.Printf("Account #%d: %x\n", i, acct)
|
||||
if arg != "" {
|
||||
// arg is an integer for the key we want to print
|
||||
i, err := strconv.Atoi(arg)
|
||||
if err != nil {
|
||||
utils.Fatalf("Must specify a valid integer argument: %v", err)
|
||||
}
|
||||
if i+1 > len(accts) {
|
||||
utils.Fatalf("Cannot get key %d; there are only %d keys, and counting starts at 0", i, len(accts))
|
||||
}
|
||||
fmt.Printf("%x\n", accts[i].Address)
|
||||
} else {
|
||||
for i, acct := range accts {
|
||||
fmt.Printf("Account #%d: %x\n", i, acct)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@ import (
|
|||
"github.com/ethereum/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
var ErrInvalidSig = errors.New("invalid v, r, s values")
|
||||
var (
|
||||
ErrInvalidSig = errors.New("invalid v, r, s values")
|
||||
ErrInvalidPubKey = errors.New("invalid public key")
|
||||
)
|
||||
|
||||
type Transaction struct {
|
||||
data txdata
|
||||
|
|
@ -200,7 +203,7 @@ func (tx *Transaction) publicKey() ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
if len(pub) == 0 || pub[0] != 4 {
|
||||
return nil, errors.New("invalid public key")
|
||||
return nil, ErrInvalidPubKey
|
||||
}
|
||||
return pub, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue