
76 Cal.App.3d 678 (1977)
143 Cal. Rptr. 153
LEATHERBY INSURANCE COMPANY, Plaintiff, Cross-defendant and Appellant,
v.
CITY OF TUSTIN, Defendant, Cross-complainant and Respondent.
Docket No. 17801.
Court of Appeals of California, Fourth District, Division Two.
December 20, 1977.
*681 COUNSEL
Anderson, McPharlin & Conners and Eric Winter for Plaintiff, Cross-defendant and Appellant.
James G. Rourke, City Attorney, and Alan R. Burns, Deputy City Attorney and Rourke & Woodruff, for Defendant, Cross-complainant and Respondent.
OPINION
McDANIEL, J.
The controversy here before us is between a bonding company and the City of Tustin over $2,166.42 plus costs of $13 and attorneys' fees awarded to Tustin on its cross-complaint. At issue essentially is the difference between a contract of indemnity and one of surety. In our view the trial court erred in opting to treat the contract involved as one of indemnity. The judgment will be modified therefore to reflect this view and, as modified, will be affirmed.
Going back to when the City of Tustin (Tustin) was engaged in widening First Street between the Newport Freeway and Prospect Avenue, it entered into a written contract for certain of this work with E.L. White Company, Inc. (White). Under the terms of that contract, White was obligated to provide Tustin with a performance bond and a so-called labor and materials bond, these respectively to assure Tustin that White would perform the contract as specified and to assure laborers on and suppliers to the job that they would be paid. Leatherby Insurance Company (Leatherby) was the surety company from which White obtained these two bonds, and in due course they were subscribed and delivered to Tustin covering work for which the general contract price was $147,004.14.
The work was undertaken, the project was finished, and thereafter a notice of completion was recorded on July 19, 1974. The record shows that Tustin had no grievances over the nature and extent of the performance of the work as such. However, White failed to pay certain of its subcontractors and suppliers. Five of this group filed stop notices with Tustin totaling in excess of $47,000 which resulted in Tustin's withholding funds otherwise payable to White in the amount of $32,136.89. Several months later certain of the stop notice claimants filed *682 suit to foreclose their stop notices[1] and among others Tustin was named as a defendant.
According to Tustin it "tendered" the defense of the claims and the suits to foreclose them to both White and to Leatherby. Neither would accept the task. Tustin then undertook to investigate the claims, to obtain extensions of time to appear in the several actions, and otherwise incurred expenses in connection therewith which the parties agree added up to $2,166.42. This sum included $1,855 in attorneys' fees, $39 in court costs and $272.42 in so-called administrative costs.
By June 6, 1975, Leatherby in its capacity as surety on the labor and materials bond had paid five stop notice claimants an aggregate of $47,624.13, and in return for such payments it obtained executed releases of the stop notices and dismissals with prejudice of the actions brought to foreclose them. On June 23, 1975, Leatherby submitted a written claim and demand to Tustin calling upon it to pay over to Leatherby the amounts previously withheld.
Tustin declined to pay over the withheld funds, and Leatherby filed suit in which it prayed for judgment of $32,136.89, plus interest from July 19, 1974, reasonable attorneys' fees, and costs. Along with its answer, Tustin filed a cross-complaint to "recover" the $2,166.42[2] previously noted, charging that "[a]s a direct and proximate result of White's and [Leatherby's] failure and refusal to pay or defend the aforementioned stop notices and claims, [Tustin] was required to expend certain funds in the amount of $2,166.42 to process and defend the aforementioned stop notices and claims."
Tustin's answer included as an affirmative defense certain new matter, also alleged in the cross-complaint, to the effect that the Tustin-White contract provided that it was subject to, and that it incorporated by reference, the standard specifications, January 1973, of the State of California, Department of Public Works. The provisions of those specifications here pertinent recite that the contractor, in this instance White, "shall protect and indemnify [Tustin] against any claims, and that *683 the duty of the contractor to indemnify and save harmless includes the duty to defend as set forth in section 2778 of the Civil Code."[3]
In Leatherby's answer to the cross-complaint, it denied that the labor and materials bond was issued for the benefit of Tustin. Leatherby also challenged Tustin's allegation that it was "required" to expend the $2,166.42, or any amount, to process and defend against the stop notice claims.
Although not part of the clerk's transcript, apparently there was a demurrer filed by Tustin. We glean this from the minute order of December 10, 1975, which reads, "Demurrering [sic] party in court by counsel James G. Rourke and Scott Nichols, a certified law clerk. Responding party plaintiff in court by counsel Eric Winter. No other appearances. Counsel stipulate and the court so orders this matter will be treated as a motion to strike. Motion to strike paragraph 12 of the complaint and paragraph 2 of the prayer granted. Notice waived." The stricken matters consisted of Leatherby's allegations of entitlement to attorneys' fees together with its prayer therefor.
With the case thus at issue, Leatherby moved for summary judgment. The supporting declaration included copies of both bonds and a *684 tabulation of the payees and amounts paid in satisfaction of White's obligations incurred in performance of the Tustin contract. Tustin responded with a counter motion for summary judgment "as prayed for in the cross-complaint."
As a consequence of the cross-motions, the court made the following order:
"1. Plaintiff and Cross-Defendant LEATHERBY INSURANCE COMPANY is entitled to the sum of $29,970.47 from Defendant and Cross-Complainant CITY OF TUSTIN, and all issues with respect to Plaintiff and Cross-Defendant's entitlement to said sum are resolved in favor of said Plaintiff and Cross-Defendant, LEATHERBY INSURANCE COMPANY;
"2. Motion for summary judgment of Defendant and Cross-Complainant CITY OF TUSTIN is denied;
"3. The issues remaining for determination of the Court shall be limited to
"(a) The entitlement of Plaintiff to interest on the principal amount of its claim,
"(b) The date from which interest shall accrue, and
"(c) The entitlement, if any, of Defendant and Cross-Complainant CITY TO [sic] TUSTIN to back charge LEATHERBY INSURANCE COMPANY for costs, administrative expenses, and attorneys' fees incurred in connection with said Defendant and Cross-Complainant's defense of claims and suits brought by stop notice claimants."
Thereafter the trial of these remaining issues was held before the court, sitting without a jury. The actual evidence introduced consisted of a stipulation of counsel which substantiated the origin of the $2,166.42 claimed by Tustin. It also recited that the notice of completion was recorded July 19, 1974, that the last stop notice release was filed June 6, 1975, and that Tustin offered to pay Leatherby the sum of $29,970.42 (sic) on May 12, 1975.
The final ruling in the case provided that Tustin have judgment against Leatherby "on the Cross-Complaint in the sum of $2,166.42, together with costs of suit of [$13] and attorneys' fees of $600.00." The *685 judgment further provided that such recovery "be applied as against Plaintiff's demand for $32,136.89 so that [Leatherby] recover judgment against [Tustin] pursuant to the Order for Summary Judgment of Judge Oliver ... in the principal sum of $29,970.47 without pre-judgment interest, with costs of [$64.10]." Leatherby has appealed.

ISSUES, DISCUSSION AND DISPOSITION
Stated in nontechnical terms, there are essentially three issues presented by the record. The first is whether Tustin was properly confirmed by the trial court in its decision to backcharge Leatherby with the $2,166.42 in expenses incurred in choosing to defend against the stop notice claims. The second involves the matter of Leatherby's right to prejudgment interest on whatever sum it was entitled to recover from Tustin. The third covers the question of attorneys' fees, and on this point Leatherby urges that it and not Tustin should receive an award of attorneys' fees.
(1a) Turning to the questioned propriety of the backcharge, we agree with Leatherby that to determine that question requires that we first define the theory on which Leatherby was entitled to any of the withheld funds in the hands of Tustin. This takes us back to the earlier order of the court which announced that Leatherby was entitled at least to $29,970.47. From this it can be concluded that Leatherby would have been entitled to recover the entire $32,136.89 of the contract retention but for the provisional ruling on the backcharge, i.e., $32,136.87 minus $2,166.42 equals $29,970.47.
The readily identifiable theory on which Leatherby was entitled to recover the contract retention is that of subrogation. When a surety pays the obligation of its principal, it is subrogated to all the rights the payees may have against others. (United States Fid. & Guar. Co. v. Oak Grove Union School Dist., 205 Cal. App.2d 226, 231 [22 Cal. Rptr. 907].) In this instance, Leatherby was entitled to the withheld funds by reason of the principal of subrogation noted, this as successor to the stop notice claimants and whatever rights to the fund they had. Accordingly, if the stop notice claimants were entitled to the entire amount of the contract retention fund, then so was Leatherby unless Tustin had a special defense or offset which it could properly assert against the stop notice claimants or against Leatherby on some direct theory. It has never been argued that the stop notice claimants would not have been entitled to recover their respective shares of the contract retention fund or that *686 Tustin had any offsets to such rights to recover. However, Tustin has argued that it does have a defense against Leatherby on a direct theory.
It was Tustin's contention to the trial court, repeated here, that Leatherby had a duty to indemnify Tustin for any expenses incurred in defending the actions brought by the stop notice claimants. This is the watershed issue. Leatherby disputes the contention that it was an indemnitor as to Tustin, and we agree with Leatherby.
The correct characterization of Leatherby's posture here is as a surety. By reason of the execution and delivery of the two bonds, Leatherby by the terms of those bonds undertook to do two things. In the case of the performance bond, it guaranteed performance of the contract according to its terms which in practice meant that if White failed to complete, Leatherby would step in and complete or pay to Tustin for its expenditures to complete either way not to exceed $147,004.14. In the case of the labor and materials bond, we find a special kind of third party beneficiary contract in which Leatherby promised Tustin that it would pay all laborers and materialmen which White failed to pay, again up to a total of $147,004.14.
From the content of the arguments presented by Tustin, we can observe that it fails to see the distinction between a contract of indemnity and one of surety. Using the named parties in illustrating the difference, if Leatherby were an indemnitor as to Tustin, the former would be in a position of having to reimburse Tustin for any amounts the latter was legally compelled to pay to the stop notice claimants which resulted in a loss to Tustin. However, as a surety, Leatherby's obligation in the form of a promise to Tustin was to pay any laborers on or suppliers to the work who were not paid by White.
In the nature of the relationship and what actually happened, Tustin would never under any circumstances be required to pay over any of its own funds to any stop notice claimant. The stop notice claimants, in suing Tustin, did not seek to recover anything but their respective shares of the contract retention representing funds which, without the intervention of the stop notices, would have been paid to White. Tustin's role in the transaction was nothing more than a stakeholder, a kind of fiduciary for the benefit of the contractor, of the stop notice claimants, or of any of their subrogees.
*687 Even assuming the actions against Tustin had gone to judgment, the total of any amounts which Tustin would have been required to pay would have been limited to the amount of the contract retention. As a consequence, there is no way it could sustain a loss such as would enable it to call upon Leatherby to indemnify it for such loss. (2) Stated otherwise, the concept of indemnity assumes that the party to be indemnified is somehow liable or obligated to another. "`"in indemnity contracts the engagement is to make good and save another from loss upon some obligation which he has incurred or is about to incur to a third person...."'" (Goodman v. Severin, 274 Cal. App.2d 885, 893 [79 Cal. Rptr. 555].)
Further language in Goodman succinctly describes the difference between an indemnity agreement and a surety contract. "`"The essential distinction between an indemnity contract and a contract of guaranty or suretyship is that the promisor in any indemnity contract undertakes to protect his promisee against loss or damage through a liability on the part of the latter to a third person, while the undertaking of a guarantor or surety is to protect the promisee against loss or damage through the failure of a third person to carry out his obligations to the promisee," [citing Somers v. United States Fid. & Guar. Co., 191 Cal. 542, 547 (217 P. 746)].'" (Goodman v. Severin, supra, 274 Cal. App.2d 885, 893.)
(1b) When the foregoing distinction is applied to the facts before us, it becomes obvious that Leatherby's posture as to Tustin was not as an indemnitor. Actually, on the labor and materials bond, Leatherby was not even a surety as to Tustin. The promisees who stood to benefit by reason of Leatherby's undertaking were the laborers and materialmen who were creditors of the contractor White.
Nevertheless, Tustin points to the $2,166.42 which it expended as being a loss for which it is entitled to indemnity. The short answer to that is that it was a needless expenditure. As suggested by Leatherby, when the suits were filed by the stop notice claimants, Tustin's decision should have been to interplead all parties with any possible claim to the contract retention by means of an action under section 386 of the Code of Civil Procedure. In such an action Tustin would have been awarded its attorneys' fees incurred in preparing, filing, and prosecuting the interpleader. Surely what Tustin chose voluntarily to expend when there was no legal necessity to do so to avoid a loss to Tustin cannot thereby be characterized as a loss. Stated another way, there has been no authority *688 cited to us for the proposition that there is a right to be indemnified for an expenditure when there was no legal necessity to make it.
Beyond the foregoing, Tustin urges that White was obligated to defend the stop notice actions by reason of incorporation into the contract between Tustin and White of the standard specifications noted earlier. Tustin argues further, because Leatherby guaranteed White's performance, that Leatherby was obligated to accept the tender of the defense of the stop notice foreclosure action. As a matter of interpretation of those standard specification provisions, Tustin is in error. The section relied upon entitled "Responsibility for Damage" contains no reference to actions sought to recover for payment for labor and materials; rather it relates to suits for wrongful death, personal injury, and property damage. The section of the standard specifications dealing with claims for labor and materials is the one calling for the contractor to provide a surety bond to assure that all such claims will be paid.
However, assuming, under the standard specifications, that a duty could be shown that called upon Leatherby to accept the tender of the defense of suits against Tustin other than for tort claims, we are confronted once again with the reality, because of the kinds of suits which were brought by the stop notice claimants, that Tustin could sustain no loss or damage as a result of those suits, i.e., there was no exposure to defend against.
Here, the analogy to the private mechanic's lien situation breaks down. If Tustin were a private property owner, then its property could be subjected to mechanic's liens and a defense against such efforts could not be characterized as voluntary. However, no such comparable remedy exists against the property of a public entity. Besides his suit for money, the only additional remedy the labor or materials claimant on public works has is by way of stop notice, and this remedy reaches only funds otherwise payable to the contractor and not funds belonging to the public entity.
Accordingly, because Leatherby, as to Tustin, never stood in the position of an indemnitor because Tustin, legally speaking, could never sustain a loss as a result of any obligation to the labor or materials claimants, it was error to allow Tustin to assert a backcharge against the contract retention.
*689 (3) That brings us to the issue of prejudgment interest. The record reflects that the releases were finally obtained from all stop notice claimants by June 6, 1975, and that Leatherby made a demand upon Tustin for the full amount of the contract retention on June 23, 1975. The record further reflects, by stipulation, that the sum of $29,970.47 was tendered by Tustin to Leatherby on May 12, 1975, to "settle" all claims and releases and hold harmless Tustin from any further claims by any parties. It is because of this tender that Tustin argues that Leatherby is not entitled to prejudgment interest. The proposition upon which Tustin's argument attempts to rely is well settled. (Civ. Code, § 1504.)[4]
However, the purported tender by Tustin was subject to three conditions which Leatherby was not obligated to satisfy. First, Leatherby was not legally obligated to settle the pending claims of White's unpaid subcontractors and suppliers. Second, Leatherby was not legally obligated to hold Tustin harmless from any pending or further claims. Third, Leatherby was not obligated to execute a release in exchange for the amount tendered. As a consequence, the tender, being conditional, was not one which came within the provisions of Civil Code section 1504.
(4) The issue of the conditional tender aside, once his stop notice claimants had been paid, White would have been entitled to disbursement to him of the contract retention. Because it was Leatherby who paid the stop notice claimants, Leatherby, because of its subrogated position, became entitled to disbursement to it of the contract retention. Generally speaking, under Civil Code section 3287, White or his subrogee Leatherby was entitled to interest after the reason for Tustin's withholding of the funds in its possession no longer obtained. The question then is to determine the date from which to calculate the interest. The last stop notice claim was released on June 6, 1975. However, knowledge of this was not communicated to Tustin until it received the demand of June 23, 1975. It was on the latter date that it came under a duty to pay over the funds, and so the interest should be reckoned from that date. (Anderson v. Pacific Bank, 112 Cal. 598 [44 P. 1063].) As stated in Anderson, "... while plaintiff was entitled to a return of his money immediately after this event, defendant was not in default until its refusal after demand to make restoration of it." (Id. at p. 603.)
*690 Moreover, because of the result reached on the main issue, recoverable interest from June 23, 1975, should be calculated on a principal sum of $32,136.89, the total amount of the contract retention to which Leatherby was entitled after it had paid off the stop notice claimants.
To this extent we do not agree with Leatherby that the stop notice claimants, had they prosecuted their claims to judgment, would have been entitled to interest from August 18, 1974, i.e., one month after the notice of completion. All they could have recovered was the amount of the contract retention fund. However, when all the claims were satisfied, there was no legal reason for Tustin to withhold, and it elected to do so at its peril after the demand. That critical date was June 23, 1975.
(5) That brings us to the matter of attorneys' fees. First, it was error to strike the provision of Leatherby's complaint relating to attorneys' fees. The right of Leatherby to attorneys' fees derives not only from the theory of subrogation, but from the circumstances that this is an action brought upon a bond. Both bonds provided that "... in case suit is brought upon this bond by the City [Tustin] or any other person who may bring an action on this bond, a reasonable attorney's fee, to be fixed by the Court, shall be paid by Principal [White] and Surety [Leatherby]." Civil Code section 1717 transforms the foregoing into one allowing White or his subrogee Leatherby, in an action on the bond, to recover attorneys' fees, if two conditions are met. It must show that (1) it is the prevailing party, and that (2) this is an action on the bond.
That Leatherby is the prevailing party is self-evident. As to the second condition, by reference to the pleadings, it can readily be determined that this action is one based upon the bond. Leatherby's position as subrogee of White and as surety on both bonds was alleged and its entitlement based on what happened after that status was established derived from that position. As a consequence of its meeting the two conditions, Leatherby was entitled to an award of attorneys' fees. Conversely it was error to award fees to Tustin, an error which occurred because of allowing the backcharge to Tustin, a result which we have already determined to have been wrong.
Accordingly, the judgment of February 22, 1977, is modified to provide that the City of Tustin recover nothing on its cross-complaint, that Leatherby Insurance Company recover judgment against the City of Tustin in the principal sum of $32,136.09, together with interest at the *691 legal rate from and after June 23, 1975, plus reasonable attorneys' fees to be fixed on motion to the court.
The judgment as thus modified is affirmed and remanded to the trial court for the fixing of a reasonable attorneys' fee for plaintiff for all proceedings in the trial court through the filing of the notice of appeal, and also for the fixing of an award of reasonable attorneys' fees on appeal. Plaintiff shall recover its costs on appeal.
Kaufman, Acting P.J., and Morris, J., concurred.
NOTES
[1]  Although not specifically indicated by the record, the parties in their briefs both take the position that these suits were to foreclose the stop notices and to recover from Leatherby on its bond, but sought no substantive relief against Tustin other than as a stakeholder.
[2]  In point of fact, this sum has at all times been in the hands of Tustin along with the $29,970.47 not now in dispute.
[3]  Section 2778 of the Civil Code reads:

"In the interpretation of a contract of indemnity, the following rules are to be applied, unless a contrary intention appears:
"1. Upon an indemnity against liability, expressly, or in other equivalent terms, the person indemnified is entitled to recover upon becoming liable;
"2. Upon an indemnity against claims, or demands, or damages, or costs, expressly, or in other equivalent terms, the person indemnified is not entitled to recover without payment thereof;
"3. An indemnity against claims, or demands, or liability, expressly, or in other equivalent terms, embraces the costs of defense against such claims, demands, or liability incurred in good faith, and in the exercise of a reasonable discretion;
"4. The person indemnifying is bound, on request of the person indemnified, to defend actions or proceedings brought against the latter in respect to the matters embraced by the indemnity, but the person indemnified has the right to conduct such defenses, if he chooses to do so;
"5. If, after request, the person indemnifying neglects to defend the person indemnified, a recovery against the latter suffered by him in good faith, is conclusive in his favor against the former;
"6. If the person indemnifying, whether he is a principal or a surety in the agreement, has not reasonable notice of the action or proceeding against the person indemnified, or is not allowed to control its defense, judgment against the latter is only presumptive evidence against the former;
"7. A stipulation that a judgment against the person indemnified shall be conclusive upon the person indemnifying, is inapplicable if he had a good defense upon the merits, which by want of ordinary care he failed to establish in the action."
[4]  Civil Code section 1504 provides: "An offer of payment or other performance, duly made, though the title to the thing offered be not transferred to the creditor, stops the running of interest on the obligation, and has the same effect upon all its incidents as a performance thereof."
