Licensing code is a pain and realistically you need to consult a lawyer who specializes in the area.
When I do freelance work I sell them the code and a perpetual use license that allows them to do pretty much anything outside of selling the code. If they want to own the code itself that's extra. But I also haven't consulted a lawyer either and I've only done that sort of transaction twice.