Whenever civil action is brought against any county treasurer, county auditor, or township, or district officer for performing or attempting to perform any duty authorized or decreed by any statute of this state for collection of the public revenue, such officer, in the discretion of the court before whom such action is brought, by an order made by said court and entered in the minutes thereof, may be allowed and paid reasonable fees for counsel and other expenses for defending such action, to be paid out of the county treasury.
N.D.C.C. § 57-45-06