I agree with Konstantinos, Jonathan, and Jeff that you should contact an attorney as soon as possible. This is a time sensitive situation so I would advise against trying to do anything on your own. There is a chance that your invention is still patentable, but that window is time sensitive as well so go see an attorney to figure out what options you have now.
It may not be a bad idea to license your software to your competitor. However, make sure to utilize trade secret/nondisclosure agreements. Your competitor should be required to sign agreements obligating them to assign all business-related IP to the company. This will strip your competitor from being sneaky and stealing your code rather than renting/licensing it. If your code is still patentable then a short-term licensing agreement would be useful. After receiving your patent, you should renegotiate the licensing agreement to reflect the added value of your newly-acquired patent.
If you’re still confused, feel free to schedule a free consultation with a software patent attorney on. We provide entrepreneurs and inventors an alternative to the more expensive big law firms law firm by leveraging better technology. Should you decide to work with the attorney, you will receive a transparent fixed-fee price quote so there’s no surprise fees and our attorneys get started the same day. Hope you find the right help.