Section 19. An assignee or receiver may compound or compromise any debt or claim due to the insolvent, if done in good faith and after proper inquiry; and, upon payment of the amount due, may require all mortgages, conditional contracts, pledges and liens, of or upon any real or personal property of the insolvent, to be satisfied, cancelled or assigned to him, as he may deem best, or he may sell the property subject thereto. Where any realty is subject to liens or claims which, under existing laws would be discharged by a judicial sale, such liens and claims shall be unaffected by a private sale of such realty; but a public sale may be made thereof, freed and clear of such liens or claims, by leave of court, after notice to the claimants; and the fund realized shall take the place of the liens or claims, and be distributed on the settlement of the account of the assignee or receiver, to the parties found entitled thereto. Executions issued on such liens or claims may be stayed by the court, to enable the property to be sold by the assignee or receiver. 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.