A Mistaken Transfer, a Debt Paid, and a Family Torn Apart

A few days ago, my ex-husband mistakenly transferred a large amount of money to me. It was early in the morning, I was asleep, and when I woke up, I found a hundred missed calls and texts asking me to return the money. But the thing is that he owed me a large amount of money for a long time (I lent it to him after the divorce, when he was broke and without a job), so I deducted the money he owed me and sent him the rest.

A scandal broke out! Turns out he had saved up to buy his new girlfriend an engagement ring, and now the engagement was off. Now his girlfriend is sending me angry messages on social media, and his parents, with whom I had a warm relationship, are on his side. We have 4 children in common, and I didn’t even deduct past due child support. Was I right to do this?