When the defendant is acquitted, either by the court or by the jury, he must be immediately discharged; and if the court certify in the minutes that the prosecution was malicious or without probable cause, it may order the prosecutor to pay the costs of the action, or to give satisfactory security by a written undertaking, with one (1) or more sureties, to pay the same within thirty (30) days after the trial.
Idaho Code § 19-3923