The original or subcontractor shall be entitled to recover, upon the claim filed by him, only such amount as may be due to him according to the terms of his contract, and, if applicable, such other amounts as may be found due to the lien claimant by the court pursuant to section 45-522, Idaho Code, after deducting all claims of other parties for work done and materials furnished to him as aforesaid, of which claim of lien shall have been filed as required by this chapter, and in all cases where a claim shall be filed under this chapter for work done or materials furnished to any subcontractor, he shall defend any action brought thereupon at his own expense; and during the pendency of such action, the person indebted to the contractor may withhold from such contractor the amount of money for which claim is filed; and in case of judgment upon the lien, the person indebted in the contract shall be entitled to deduct from any amount due or to become due by him to such contractor, the amount of such judgment and costs; and if the amount of such judgment and costs shall exceed the amount due from him to such contractor, if the person indebted in the contract shall have settled with such contractor in full, he shall be entitled to recover back from such contractor any amount so paid by him in excess of the contract price, and for which such contractor was originally the party liable.
Idaho Code § 45-511