The IRS ruled that bitcoins and other cryptocurrencies are property, not currency. As such, you determine gain or loss in the same was as any other type of property. Compare what you paid for the bitcoins and what you received on the sale (making adjustments for commissions, etc.).
When debts are cancelled in bankruptcy cases, the cancelled amount is excluded from gross income. Tax attributes are certain losses, credits, and property basis that must be reduced to the extent of the exclusion.