If such bond, if any, as has been required by the court, has been given, the title acquired through any sale, mortgage, lease or exchange made pursuant to a decree of the court shall be indefeasible by any person ascertained or unascertained, or any class of persons, referred to in the petition or decree and having a present or expectant interest in the property, and shall be unprejudiced by any error in the proceedings. No party who pays cash or other consideration pursuant to the decree shall be liable to see to the proper application thereof, nor shall he be in any manner subject to any trust limitation on, or defect in, the title set out in the petition or decree. Any sale or exchange under this chapter shall have the effect of a judicial sale as to the discharge of liens, but the court may decree a sale or exchange freed and discharged from the lien of any mortgage otherwise preserved from discharge by existing law, if the holder of such mortgage shall so consent by writing filed in the proceeding.