If a creditor purchases property upon which he has a lien or claim, he shall, after payment to the assignee or receiver of all the costs and expenses of the sale, and the amount of all prior liens or claims discharged by the sale, if any, be entitled to receipt to the assignee or receiver to the extent of his lien or claim, upon giving security, to be approved by the court, conditioned to make good the amount receipted for if it shall afterwards be made to appear that, for any cause, he should not be allowed such preference.
39 P.S. § 78