MR. JUSTICE HOLLOWAY
delivered the opinion of the court.
From the first Monday in May, 1905, to the first Monday in May, 1907, Phil. C. Goodwin was city treasurer of the city of Butte, and during that period it is claimed that he had on deposit with a bank large sums of public funds of the city, upon which the bank paid him interest in amounts aggregating $4,243.39. It is to recover this money that this suit was brought by the city against Goodwin and the sureties on his official bond. It is alleged that notwithstanding he received this amount of interest upon the public funds belonging to the city, he failed and refused to account for or pay over such amount, or any part thereof, to the city or to his successor in office, but wrongfully converted the same to his own use. By separate answer Goodwin denied generally all the wrongful acts charged against him, and pleaded the bar of the statute of limitations. The sureties joined in a separate answer which, to all intents and purposes, is identical with the answer interposed by Goodwin. After plaintiff had concluded its evidence upon the trial of *163the cause, the court sustained a motion by defendants for a non-suit, upon the ground that at the time of its commencement the plaintiff’s action was barred. Judgment was rendered and entered in favor of defendants, and it is from that judgment that the city appealed.
1. That it was the duty of Goodwin to turn over to the city the interest earned by the public funds of the city while in his possession is not controverted by his counsel, and could not be. Whatever may be the rule in jurisdictions where the city [1] treasurer is an insurer of the public funds, in this state, where that doctrine does not prevail (City of Livingston v. Woods, 20 Mont. 91, 49 Pac. 437), he is, in point of law, a trustee of the funds for the use of the city, and under the most elementary rules of law must account for and pay over any profits derived from the use of the trust fund. (United States v. Mosby, 133 U. S. 273, 33 L. Ed. 625, 10 Sup. Ct. Rep. 327; State v. McFetridge, 84 Wis. 473, 20 L. R. A. 223, 54 N. W. 1, 998; Rhea v. Brewster, 130 Iowa, 729, 8 Ann. Cas. 389, 107 N. W. 940.)
2. The statutes of limitation pleaded, and relied upon by defendants upon the motion for nonsuit, are subdivision 3 of section 6447, Revised Codes, which provides that an action upon an obligation or liability, not founded upon an instrument in writing, other than a contract, must be commenced within three years; and subdivision 1 of section 6449, which provides that an action upon a liability created by statute, other than a penalty or forfeiture, must be commenced within two years.
Goodwin’s term of office expired and he was relieved by his successor on the first Monday in May, 1907. This action was not commenced until May 27, 1911, and the important question for determination is: Was the action barred? The trial court held that the action is one upon a liability created by statute and barred within two years by the provisions of subdivision 1 of section 6449 above. However, if the action was barred by either statute relied upon, the conclusion of the trial court will be sustained; for it is settled in this state that if a party [2] is entitled to an order, the action of the court in granting *164it will be affirmed even though the particular reason given for the ruling may be erroneous. (Harrington v. Butte etc. Ry. Co., 36 Mont. 478, 93 Pac. 640.) “If the court’s ruling was correct, it is immaterial that it was founded upon an erroneous reason.” (Brown v. Daly, 33 Mont. 523, 84 Pac. 883.) While cases may be found holding that an action of this character is one upon a liability created by statute, a review of the history [3] of the origin and purpose of that statute (subd. 1, sec. 6449 above) will demonstrate at once that it was never intended to apply to an action of the character of the one now before us. Since, however, the discussion of the question is not of any particular consequence here, we content ourselves with a reference to Kelly on Code Statute of Limitations, Chapter XX, for the history of the provision.
We agree with counsel for appellant in their terse statement of the character of Goodwin’s liability, as follows: “Twist it as one may, the liability finds its root and substance in the implied promise, the equitable promise that the law makes for a trustee, whether he will or no, to answer and account for, and pay over to his beneficiary, the secret profits of the beneficiary’s money. The law says a man is not permitted to assert anywhere, in any court, that he has not conscience enough to make such a promise. ' Equity refuses to allow a man to so abase himself, and this proposition of equity has so long endured that even under the most rigid terms of the common-law procedure the action was for a century, at common law, on an implied assumpsit to make the defendant pay over to the plaintiff that which the defendant had of the plaintiff, and which in equity and good conscience should be restored.” And again: “Either the treasurer is liable at common law and on the equitable principle of an implied promise which has been so long grafted into the common law as to become a part thereof, or he is not liable at all. ’ ’
In Schaeffer v. Miller, 41 Mont. 417, 137 Am. St. Rep. 746, 109 Pac. 970, we considered the character of such a liability and held that it arises from a breach of an obligation or legal duty, and that an action upon such obligation is barred by the provisions of subdivision 3 of section 6447, unless commenced within three *165years after the cause of action accrues. Notwithstanding the clear and forceful expression of the rule of Goodwin’s liability by counsel for the city as set forth above, they insist nevertheless that this action is one upon a contract, obligation or liability founded upon an instrument in writing, or, in other words, that it is an action for the breach of a contract in writing and covered by the eight-year period prescribed in section 6445. If it is an action upon the bond and the bond is a contract, then it is upon an express promise, and if upon an express promise, it could not be upon an implied one. But counsel are right in their statement as to the character of Goodwin’s liability. The obligation sued on is not founded upon any instrument in writing, but rests altogether upon the rule of law which makes the promise for the trustee that he will account for and pay over all the earnings of the trust fund while in his possession, and the cause of action arises upon a breach of the duty thus imposed by law. If this action is based upon the bond, then for every violation of official duty which amounts to a breach of the obligation of the officer’s bond an action might be maintained if brought within eight years after the cause of action accrues; but that this is not so the statute itself demonstrates. If a sheriff willfully permits the escape of a prisoner arrested on civil process, his act would constitute a breach of official duty for which he and his bondsmen would be liable; but the action would have to be brought within one year, under section 6450, notwithstanding the existence of the bond. So, likewise, if such sheriff should collect money on execution and wrongfully fail to pay it over to the party entitled, this would constitute a breach of duty and give rise to an action against him and his bondsmen, but such action would have to be commenced within three years, under subdivision 1 of section 6447. If the city treasurer wrongfully seizes the property of A for taxes when none are due, such an act would give rise to a cause of action in favor of A and against the treasurer and his bondsmen for damages for the wrongful seizure; but such action would have to be brought within one year under section 6450, notwithstanding the existence of the treasurer’s official bond. So, likewise, if *166the city treasurer retains interest on public funds and fails to [4] turn it over to the city, he is guilty of a breach of the obligation of his official bond, but this is so only because he is likewise guilty of a breach of his implied promise to pay over such interest. It is this breach of his obligation or legal duty which gives rise to a cause of action, and such action must be brought within three years after the cause of action accrues, under subdivision 3 of section 6447 above. (Schaeffer v. Miller, above.) The illustrations might be multiplied many times, but these suffice to indicate that the period of time during which an action may be brought against a public officer depends upon the character of his wrongful act, and not upon the fact that he has given a bond in writing for the faithful performance of official duties. The duty of the city treasurer to pay over the interest earned on the city’s funds depended, not upon his bond, but upon his implied promise to do that which in equity and good conscience he ought to do. The duty was imposed by law and was not affected in the least by the giving of the bond. Goodwin’s liability would have been precisely the same if he had performed the services without any official bond, or if he had failed to sign the bond which he did give. If the city has a cause of action against Goodwin, it arises from his wrongful act in retaining money which belonged to the city- — if he did so— and not upon the violation of any express contract. If the city treasurer had not given any bond at all but had performed the duties of city treasurer and had received the interest which it is alleged he did receive, his duty to pay it over to the city would have been the same; his liability for failure to do so the same; the city’s cause of action just the same, and the proof necessary to make out a case the same as in the present instance. (Paige v. Carroll, 61 Cal. 211; Ryus v. Gruble, 31 Kan. 767, 3 Pac. 518; Spokane County v. Prescott, 19 Wash. 418, 67 Am. St. Rep. 733, 53 Pac. 661; State v. Conway, 18 Ohio, 234.) Goodwin’s failure to sign the bond would not have vitiated it or lessened his liability, and if he had not signed the bond, there cannot be any question that the action against him would have been barred in three years, and if barred -as to the principal it would have been *167barred as to the sureties, notwithstanding they had signed the bond (State v. Kelly, 32 Ohio St. 421; Ryus v. Gruble, above; State v. Conway, above); for the bond is not a contract in the strict sense of the term. It is a sort of vicarious undertaking— [5] a collateral security for the faithful performance of official duty. (County of Sonoma v. Hall, 132 Cal. 589, 62 Pac. 257, 312, 65 Pac. 12, 459; Oregon v. Davis, 42 Or. 34, 71 Pac. 68, 72 Pac. 317; Walton v. United States, 9 Wheat. (U. S.) 651, 6 L. Ed. 182.)
Since the action was not commenced for more than four years after the conclusion of Goodwin’s term of office, it was barred by the provisions of subdivision 3 of section 6447.
3. In view of what we have said, it is quite immaterial whether the bond in question is strictly a statutory bond. It was Goodwin’s official bond, is so designated in the complaint, and the liability of his sureties is not extended by any terms found therein, so far as the question now presented upon the application of the statute of limitations is involved.
4. When it appeared from the plaintiff’s evidence that its [6] cause of action was barred, it became the duty of the trial court to sustain the motion of these defendants for a nonsuit. (Chowen v. Phelps, 26 Mont. 524, 69 Pac. 54.)
The judgment is affirmed.
Affirmed.
Mr. Chief Justice Brantly concurs.
Mr. Justice Sanner: The above opinion establishes that the suit at bar is not upon a liability created by statute; that whatever interest Goodwin may have collected belonged to the city; that it was his duty to pay over or account for all moneys belonging to the city, whether principal or interest; and with all of this I agree. But I. cannot assent to the conclusion that this action is barred because “upon an obligation or liability, not founded upon an instrument in writing, other than a contract, account or promise.” (Subd. 3, sec. 6447, Rev. Codes.) It is quite true that in Schaeffer v. Miller, 41 Mont. 417, 137 Am. St. Rep. 746, 109 Pac. 770, and other decisions of this court prior *168thereto, it is held that an action upon a constructive promise which has no foundation other than equity and good conscience, is barred by the above statute, on the theory that such a promise is no promise but a pure fiction of law; hence, if the language quoted from appellant’s brief is to be taken as grounding its right to recover on such a promise and is binding on this court, the conclusion reached in the opinion is inevitable. As I understand the position of appellant, however, it is that this action is founded upon an express contract; that lying behind, justifying and furnishing the basis for the express contract is the common-law liability upon a promise to be implied from Goodwin’s acceptance of the office, and which equity and good conscience will not permit him to deny. Whatever be the correct interpretation, I do not feel any more bound by the reasons of counsel than the opinion is by the reasons of the trial court.
It is required by the ordinances of the city of Butte that the treasurer “before entering upon the duties of his office, shall execute a bond to the city of Butte, with good and sufficient sureties,” etc. In my judgment, there is here furnished sufficient consideration, sufficient explanation and sufficient requirement for the signature of the treasurer as it appears upon the instrument before us; that instrument contains the express stipulation on the part of Goodwin and his sureties that he shall pay over and faithfully account for all moneys coming into his hands belonging to the city; if he has not done this, I cannot understand how it can be that this express stipulation has not been violated, or why that violation is not the basis of his and their liability.
In Schaeffer v. Miller a clear distinction is made between those implied promises which-are pure fictions of law, and those which arise from the conduct of the party sought to be charged. In the latter instance it is conceded that a true promise exists. Now, although a public office is not a contract, there is, I think, a true promise to be inferred from a public treasurer’s acceptance of office, that he will pay over and faithfully account for all public moneys that may come into his hands by virtue of the office. That promise I conceive Goodwin to have made apart *169from the bond; that promise was formally reiterated in set terms in the bond; and that promise applied to all moneys of the city coming into his hands, from whatever source derived. Implication may be necessary to the conclusion that the interest belonged tó the city, but that the promise of Goodwin to pay over and faithfully account for the city’s money is a pure fiction of law, I cannot believe.
Rehearing denied May 7, 1913.
Neither can I see any convincing reason for the rule announced in the opinion, in the fact that Goodwin’s duty would have been the same if he had not signed nor given any bond; the fact remains that he did execute and give it. The concept of duty is undoubtedly back of Goodwin’s liability, as it may fairly be said to be “the root” of all liability whatsoever. Breach of duty in some form is a necessary‘ingredient in every case; but that does not alter the fact that when the duty is formally expressed by written instrument, causes of action may be and often are founded, within the meaning of the statute of limitation, upon the instrument, even though no legal necessity existed for the execution of it.
So, I think the judgment is erroneous, even under the holding that “an official bond is not a contract in the strict sense of the term, but a sort of vicarious undertaking — a collateral security for the faithful performance of official duty.” The effect of this rule is to gauge the liability of the sureties in all cases by that of the principal. If Goodwin was required to and did execute the bond, this action, as I see it, is not barred as to him. If his liability endures, that of the sureties endures also.