When a party entitled to a share in the property, or an encumbrancer entitled to have a lien paid out of the proceeds of the same, becomes a purchaser, the referees may take the receipt for so much of the proceeds of the sale as belong to the entitled party or encumbrancer. They shall also pay over to the plaintiff or the plaintiff’s attorney, and take the plaintiff’s receipt for, the costs and charges of the action.