Bummer!
Yes, this type of crap will always happen when buying a less-than-new house. That's why you have to be ready for it before you finalize the sale.
20/20 hindsight of course, but ya shouda had a Repair Allowance written into your offer as soon as you saw the many signs of the dodgy wiring. Better yet, you should have had it inspected by an electrician and
then used the amt. of his estimate for the Repair Allowance amount.
Did you use a Realtor™?