If you meet the Substantial Presence Test you must pay tax in the U.S. on your worldwide income including unearned income.
Note - you may still be required to pay tax in country X. There are various methods to avoid double taxation. The most common method is claiming Foreign Tax Credit on your U.S. return for tax paid in country X. Some countries with a Tax Treaty may accept Form 6166 - Certification of U.S. Tax Residency and allow for a tax exemption.