cosmos-sdk/x/auth/client/util.go

28 lines
540 B
Go

package client
import (
"io/ioutil"
"os"
"github.com/tendermint/go-amino"
"github.com/cosmos/cosmos-sdk/x/auth"
)
// Read and decode a StdTx from the given filename. Can pass "-" to read from stdin.
func ReadStdTxFromFile(cdc *amino.Codec, filename string) (stdTx auth.StdTx, err error) {
var bytes []byte
if filename == "-" {
bytes, err = ioutil.ReadAll(os.Stdin)
} else {
bytes, err = ioutil.ReadFile(filename)
}
if err != nil {
return
}
if err = cdc.UnmarshalJSON(bytes, &stdTx); err != nil {
return
}
return
}