ErrTxParse->ErrTxDecode; check for empty bytes in account and tx
This commit is contained in:
@@ -122,11 +122,15 @@ func MakeCodec() *wire.Codec {
|
||||
func (app *BasecoinApp) txDecoder(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||
var tx = sdk.StdTx{}
|
||||
|
||||
if len(txBytes) == 0 {
|
||||
return nil, sdk.ErrTxDecode("txBytes are empty")
|
||||
}
|
||||
|
||||
// StdTx.Msg is an interface. The concrete types
|
||||
// are registered by MakeTxCodec in bank.RegisterWire.
|
||||
err := app.cdc.UnmarshalBinary(txBytes, &tx)
|
||||
if err != nil {
|
||||
return nil, sdk.ErrTxParse("").TraceCause(err, "")
|
||||
return nil, sdk.ErrTxDecode("").TraceCause(err, "")
|
||||
}
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@ func (acc *AppAccount) SetName(name string) { acc.Name = name }
|
||||
// Get the AccountDecoder function for the custom AppAccount
|
||||
func GetAccountDecoder(cdc *wire.Codec) sdk.AccountDecoder {
|
||||
return func(accBytes []byte) (res sdk.Account, err error) {
|
||||
if len(accBytes) == 0 {
|
||||
return nil, sdk.ErrTxDecode("accBytes are empty")
|
||||
}
|
||||
acct := new(AppAccount)
|
||||
err = cdc.UnmarshalBinary(accBytes, &acct)
|
||||
if err != nil {
|
||||
|
||||
@@ -64,7 +64,7 @@ func decodeTx(txBytes []byte) (sdk.Tx, sdk.Error) {
|
||||
k, v := split[0], split[1]
|
||||
tx = kvstoreTx{k, v, txBytes}
|
||||
} else {
|
||||
return nil, sdk.ErrTxParse("too many =")
|
||||
return nil, sdk.ErrTxDecode("too many =")
|
||||
}
|
||||
|
||||
return tx, nil
|
||||
|
||||
Reference in New Issue
Block a user