diff --git a/api/accounts.go b/api/accounts.go index 4c586a05c..b80fe72b2 100644 --- a/api/accounts.go +++ b/api/accounts.go @@ -180,6 +180,12 @@ func (a *API) accountHandler(_ *apirest.APIdata, ctx *httprouter.HTTPContext) er // @Router /accounts [post] func (a *API) accountSetHandler(msg *apirest.APIdata, ctx *httprouter.HTTPContext) error { req := &AccountSet{} + if msg == nil { + return ErrCantParseDataAsJSON + } + if msg.Data == nil { + return ErrCantParseDataAsJSON + } if err := json.Unmarshal(msg.Data, req); err != nil { return err } @@ -187,10 +193,16 @@ func (a *API) accountSetHandler(msg *apirest.APIdata, ctx *httprouter.HTTPContex // check if the transaction is of the correct type and extract metadata URI metadataURI, err := func() (string, error) { stx := &models.SignedTx{} + if req.TxPayload == nil { + return "", ErrUnmarshalingServerProto + } if err := proto.Unmarshal(req.TxPayload, stx); err != nil { return "", err } tx := &models.Tx{} + if stx.GetTx() == nil { + return "", ErrUnmarshalingServerProto + } if err := proto.Unmarshal(stx.GetTx(), tx); err != nil { return "", err } @@ -231,6 +243,9 @@ func (a *API) accountSetHandler(msg *apirest.APIdata, ctx *httprouter.HTTPContex if err != nil { return err } + if res == nil { + return ErrVochainSendTxFailed + } // prepare the reply resp := &AccountSet{