diff --git a/pkg/core/native/native_neo.go b/pkg/core/native/native_neo.go index e1d5d3f50..295a9d8f7 100644 --- a/pkg/core/native/native_neo.go +++ b/pkg/core/native/native_neo.go @@ -726,6 +726,18 @@ func (n *NEO) VoteInternal(ic *interop.Context, h util.Uint160, pub *keys.Public if err != nil { return err } + if pub != nil { + valKey := makeValidatorKey(pub) + valSi := ic.DAO.GetStorageItem(n.ID, valKey) + if valSi == nil { + return errors.New("unknown validator") + } + cd := new(candidate).FromBytes(valSi) + if !cd.Registered { + return errors.New("validator must be registered") + } + } + if (acc.VoteTo == nil) != (pub == nil) { val := &acc.Balance if pub == nil { @@ -765,8 +777,6 @@ func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *b if ok { return err } - } else if !cd.Registered { - return errors.New("validator must be registered") } n.validators.Store(keys.PublicKeys(nil)) return d.PutStorageItem(n.ID, key, cd.Bytes())