diff options
author | Felix Lange <fjl@twurst.com> | 2016-03-03 08:09:16 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-04-12 21:58:01 +0800 |
commit | 46e8940b19fee9bc21767a1341c382fd9c9d572a (patch) | |
tree | 384b700810910857cd40e099aba0d5a525eec066 /cmd/utils | |
parent | 2dc20963e789c85bcc9170e15c0483e51ca42bfc (diff) | |
download | go-tangerine-46e8940b19fee9bc21767a1341c382fd9c9d572a.tar go-tangerine-46e8940b19fee9bc21767a1341c382fd9c9d572a.tar.gz go-tangerine-46e8940b19fee9bc21767a1341c382fd9c9d572a.tar.bz2 go-tangerine-46e8940b19fee9bc21767a1341c382fd9c9d572a.tar.lz go-tangerine-46e8940b19fee9bc21767a1341c382fd9c9d572a.tar.xz go-tangerine-46e8940b19fee9bc21767a1341c382fd9c9d572a.tar.zst go-tangerine-46e8940b19fee9bc21767a1341c382fd9c9d572a.zip |
accounts: streamline API
- Manager.Accounts no longer returns an error.
- Manager methods take Account instead of common.Address.
- All uses of Account with unkeyed fields are converted.
Diffstat (limited to 'cmd/utils')
-rw-r--r-- | cmd/utils/flags.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c87c2f76e..da29ceb09 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -564,27 +564,23 @@ func MakeAccountManager(ctx *cli.Context) *accounts.Manager { // MakeAddress converts an account specified directly as a hex encoded string or // a key index in the key store to an internal account representation. -func MakeAddress(accman *accounts.Manager, account string) (a common.Address, err error) { +func MakeAddress(accman *accounts.Manager, account string) (accounts.Account, error) { // If the specified account is a valid address, return it if common.IsHexAddress(account) { - return common.HexToAddress(account), nil + return accounts.Account{Address: common.HexToAddress(account)}, nil } // Otherwise try to interpret the account as a keystore index index, err := strconv.Atoi(account) if err != nil { - return a, fmt.Errorf("invalid account address or index %q", account) + return accounts.Account{}, fmt.Errorf("invalid account address or index %q", account) } - hex, err := accman.AddressByIndex(index) - if err != nil { - return a, fmt.Errorf("can't get account #%d (%v)", index, err) - } - return common.HexToAddress(hex), nil + return accman.AccountByIndex(index) } // MakeEtherbase retrieves the etherbase either from the directly specified // command line flags or from the keystore if CLI indexed. func MakeEtherbase(accman *accounts.Manager, ctx *cli.Context) common.Address { - accounts, _ := accman.Accounts() + accounts := accman.Accounts() if !ctx.GlobalIsSet(EtherbaseFlag.Name) && len(accounts) == 0 { glog.V(logger.Error).Infoln("WARNING: No etherbase set and no accounts found as default") return common.Address{} @@ -594,11 +590,11 @@ func MakeEtherbase(accman *accounts.Manager, ctx *cli.Context) common.Address { return common.Address{} } // If the specified etherbase is a valid address, return it - addr, err := MakeAddress(accman, etherbase) + account, err := MakeAddress(accman, etherbase) if err != nil { Fatalf("Option %q: %v", EtherbaseFlag.Name, err) } - return addr + return account.Address } // MakeMinerExtra resolves extradata for the miner from the set command line flags |