In this paper, a transient stability margin is proposed in terms of the kinetic energy of power systems in extremely unstable conditions. A unified energy-based transient stability constraint is formed for both normal and extremely unstable conditions in the proposed transient stability-constrained optimal power flow (TSCOPF) model. A divide-and-conquer approach is presented to solve TSCOPF by decomposing it into optimal power flow and transient stability-constrained generation sub-problems. The former is solved by an interior point method and the latter is derived by an energy sensitivity technique. Furthermore, an accuracy-based perturbation strategy is proposed to address the system over-stabilization issue, and a parallel calculation technique is implemented to speed up the TSCOPF solution. The effectiveness of the proposed approach is investigated and the results are validated using the New England 10-generator and IEEE 50-generator systems under extremely unstable conditions.