A fast discrete curvelet transform based focus-stacking algorithm for extending the depth of focus of a transmission x-ray microscope (TXM) is presented. By analyzing an image stack of a sample taken in a Z-scan, a fully in-focus image can be generated by the proposed scheme. With the extended depth of focus, it is possible to obtain 3D structural information over a large volume at nanometer resolution. The focus-stacking method has been demonstrated using a dataset taken with a laboratory x-ray source based TXM system. The possibility and limitations of generalizing this method to a synchrotron based TXM are also discussed. We expect the proposed method to be of important impact in 3D x-ray microscopy.