Crazy tidbit about Judah and Tamar from Guide for the Perplexed: Maimonides says the same business deal underlies contracting a wife and contracting a prostitute. Both have conditions and exit fees, if you will, that both parties agree to beforehand. (The conditions and fees–payable to the wife unless she broke the contract–are called the ketubah.)
So, since Tamar evaded being paid the exit fee, the goat kid, Judah was still contractually obligated to her like (not as necessarily, but like) a wife! That would mean that the children were legitimate.
I tried to figure out if she lived as a wife after the birth of the children, but Genesis doesn’t say much about it other than to say that Judah never knew her again.
The Judah/Tamar exchange intrigues me to no end. I keep–unsuccessfully–trying to write the screenplay of Tamar’s story. She may be more righteous than Judah (so he says) and more righteous than we think.