Deductions & credits

The capital gains from the sale of the house is taxed regardless of what you do with the money next.   However, if this was your main house that you owned and lived in for at least 2 years before the sale, you may be able to exclude up to $250,000 of the gain from any tax (or $500,000 if married filing jointly.)

 

Review publication 523.

https://www.irs.gov/forms-pubs/about-publication-523

 

Your gain is the difference between the selling price and the purchase price (after certain adjustments as allowed in publication 523), which may have very little to do with the amount of actual cash you took out of the deal.