cosmos-sdk/cmd/basecoin/account.go

32 lines
605 B
Go
Raw Normal View History

2017-01-29 11:41:21 -08:00
package main
import (
"encoding/hex"
"errors"
"fmt"
"github.com/urfave/cli"
"github.com/tendermint/go-wire"
)
func cmdAccount(c *cli.Context) error {
if len(c.Args()) != 1 {
return errors.New("account command requires an argument ([address])")
}
2017-01-29 13:34:48 -08:00
addrHex := stripHex(c.Args()[0])
2017-01-29 11:41:21 -08:00
// convert destination address to bytes
addr, err := hex.DecodeString(addrHex)
if err != nil {
return errors.New("Account address is invalid hex: " + err.Error())
}
2017-01-29 13:34:48 -08:00
acc, err := getAcc(c.String("tendermint"), addr)
2017-01-29 11:41:21 -08:00
if err != nil {
return err
}
fmt.Println(string(wire.JSONBytes(acc)))
return nil
}