You do not have to wait until a debt is due to determine whether it is worthless. A debt becomes worthless when there is no longer any chance the amount owed will be paid.
It is not necessary to go to court if you can show that a judgment from the court would be uncollectible. You must only show that you have taken reasonable steps to collect the debt. Bankruptcy of your debtor is generally good evidence of the worthlessness of at least a part of an unsecured and unpreferred debt. taxmap/pubs/p535-053.htm#en_us_publink1000154200
If you receive property in partial settlement of a debt, reduce the debt by the FMV of the property received. You can deduct the remaining debt as a bad debt if and when it becomes worthless.
If you later sell the property, any gain on the sale is due to the appreciation of the property. It is not a recovery of a bad debt. For information on the sale of an asset, see Publication 544.