Waterman, J.
1 The Sioux City Terminal Railroad & Warehouse Company was organized and duly incorporated under the laws of this state. The purpose of its organization, as stated in the articles of incorporation, was to construct, operate, and maintain one or more lines of railway within the corporate limits of Sioux City, Iowa, with all needed side tracks, depot yards, warehouses, storage houses, elevators, and all other needed terminal facilities; and shall have power to acquire by purchase or condemnation all needed grounds for right of way, depot purposes, and side tracks, wood and water stations, and to hold, use, and control the same; and shall have power to' construct, operate, and control one or more lines of railway from the depot and yards of ■said company in Sioux City, — one to run in an easterly direction to the east line of Woodbury county, Iowa, one to run in a westerly direction to the Big Sioux river, and one in a northerly direction to the Iowa state line; and shall have power to lease grounds and buildings, to purchase and hold all needed grounds for the use and purpose of said company, and to mortgage, lease, or sell the said grounds, and improvements thereon.” Proceeding to' carry out this plan, a contract was made with Wakefield to erect for it a passenger station and train sheds, and the various controversies here grow out of that undertaking.
*5732 I. The GilletttedEEerzog Company was a sub-contractor under Wakefield. It filed a cross-petition in this action, claiming to be a creditor of Wakefield, and asked a judgment against him for the sum of twelve thousand eight hundred and forty-five dollars and ninety-one cents and interest, and for the establishment and foreclosure of a mechanic’s lien against a part of the Terminal property. This relief was granted, and complaint is made by Wakefield of this action of the trial court. It seems that in April, 1893, Wakefield gave said company the following written order on the Terminal Company, the amount named therein being the full sum due on its contract:
“April 1, 1893. Messrs. The Sioux City Terminal Railroad & Warehouse Company, Sioux City, Iowa — Gentler men: Please pay to the order of the GilletteTTerzog Manufacturing Company $23,190 36-100 (twenty-three thousand one hundred and ninety and.36-100 dollars), in full settlement of my note for $10,000.00, and of their account for material furnished and labor performed'in connection with the structure ironwork for your depot and train shed. E. C. Wakefield.
“This note accepted April 1. George Walter Oakley, Treasurer.”
*5743 *573As appears upon its face, t-his order was accepted by the drawee. Shortly after this transaction the Terminal Company paid the sum of ten thousand dollars' on this order, and later gave the Gillette Company a check for five thousand seven hundred and twenty-two dollars and ninety-four cents, the same being drawn on the Trust Company of North America. This check was not honored. A certain reduction in the amount of the Gillette Company’s claim was afterwards made on account of freight charges paid by Wakefield. We do not discover that the amount found due on this claim is questioned, but it is said that the order on the Terminal Company was given by Wakefield and accepted by the Gillette *574Company in full satisfaction and payment of the latter’s account. The rule is that the giving of an order on a third person will operate as payment of a precedent debt, if there is an express agreement to that effect. Farwell v. Salpaugh, 32 Iowa, 582; Huse v. McDaniel, 33 Iowa, 406; 2 Daniel Negotiable Instruments, 1262. There is evidence showing that at the time this order was given the parties spoke of it as being in settlement and full satisfaction of the account, and that the Gillette Company afterwards asserted that it had no claim against Wakefield. This evidence is uncontradicted. Indeed, counsel for the Gillette Company does not seriously contend that this was not payment. His main effort to sustain the finding of the lower court is grounded upon the claim that the order operated as an assignment of the fund, and that a right to a lien passed by the assignment. Under our finding of fact that the acceptance of the order was a payment of the claim as far as Wake-field is concerned, it is manifest that the Gillette Company is not entitled to a personal judgment against him, and it is insisted by counsel who resist this claim that it has no right to a mechanic’s lien. The claim of an equitable assignment of Wakefield’s right is met with the assertion that it is only the perfected lien that is assignable, and not a mere inchoate right to a lien. We have quite lately held that the right to a lien is assignable before the statement therefor is filed, if the parties so intend. Peatman v. Power Co., 105 Iowa, 1. But, as we see this ease, that question is not involved. The Gillette Company is not claiming Wakefield’s right tO' a lien through an assignment, but its own right based on its claim as a sub-contractor. The real question is, has it lost the right which it admittedly once had ? Wakefield has paid it, so far as he is concerned, by giving an order on the owner; that is, he has canceled his personal liability. But we hardly think this transaction can stand in the way of an enforcement of the sub-contractor’s rights against the property. A sub-contractor, it is true, cannot enforce his lien against the owner *575until his account against the principal contractor has been established or adjudicated. Simonson Bros. Mfg. Co. v. Citizens’ State Bank, 105 Iowa, 264; Vreeland v. Ellsworth, 71 Iowa, 347. And it has been held that the right of a laborer or sub-contractor must be enforced through his employer or principal. Utter v. Crane, 37 Iowa, 631. This last case is thought to be decisive against the claim of the Gillette Company to a lien. All that was decided in the Utter Case was that a laborer had no right agaipst the principal contractor when the sub-contractor by whom such laborer was employed had been paid in full according to the terms of his contract. In the case at bar the amount of the claim against the principal contractor has been settled by the agreement, and the Gillette Company is seeking its rights through Wakefield, though not necessarily against him. The giving and receiving of this order amounted to no more than an agreed statement of the amount of the Gillette Company’s claim, and its acceptance by the Terminal Company was but a recognition of this fact, and a promise to pay. We are at a loss to see how this transaction deprived the sub-contractor of its light to a lien. In addition to what has been said, we may add that the amount for which Wakefield is claiming a lien seems to include the Gillette Company’s account. The decree of the trial court fixes the order of priority of the mechanics’ liens, and the Gillette Company is ranked No. 13. Counsel insist here that it should have the second place. No reason is given in support of this claim, and we are unable to find any in the record. We do find, however, that it is entitled to the eleventh place in the list.
II. The next two questions that arise are intimately connected: (1) For what amount should Wakefield be allowed a lien? It is not disputed that he is entitled to a lien for some amount, but it is most earnestly insisted on behalf of the Trust Company that the trial court allowed him far more than was due. (2) The next question is one of priority, and arises between Wakefield and those claiming *576rights under the trust deed to the Trust Company of North America. We shall take these matters up in the order stated.
*5784 5 *5806 *576Wakefield was awarded a judgment for fifty-nine thousand six hundred and eighty-two dollars and sixty-eight cents. This amount seems to have been allowed on the strength of a settlement and adjustment of the account had by Wakefield with A. S. Garretson, the president and active manager of the Terminal Company. More will be said of this alleged settlement later. We only wish to say at this time that the items are not given in the record, from which the amount so allowed can be made up. It is undisputed, however, that Garretson allowed Wakefield’s account in the sum of fifty-one thousand ten dollars and eighty-four cents. This, with interest thereon, would make up the amount awarded by the trial court. We shall now go to the record, and see how Wakefield’s account stands according to the figures there appearing. The contract price for the depot building was one hundred and thirty-five thousand six hundred and fifty-six dollars. Before its completion, Wakefield abandoned the work, and the structure was finished by the Terminal Company at a cost of twenty-one thousand two hundred and ninety-seven dollars and seventy cents. This would leave a net sum due the contractor of one hundred and fourteen thousand three hundred and fifty-eight dollars and thirty cents. Of this amount, one hundred and five thousand eight hundred and thirty-seven dollars and twenty-five cents was paid him during the progress of the work, leaving still due of the contract price eight thousand five hundred and twenty-one dollars and five cents. These amounts are not disputed, save that paid for completing the building. As to this, we think the figures given are sustained by the testimony. In addition to this, Wakefield had a claim for extra work done. He-says now that this was sufficient in amount to increase his account to the sum allowed in the settlement. On April 25,. 1893, he filed a claim for a mechanic’s lien, in which he set forth the extra work as of the value of seven thousand four' hundred and sixty-eight dollars. Again, we find in the record" *577that in September, 1893, Wakefield submitted to the architects of the building, who had a right of supervision and decision of such matters under the building contract, his claim for extras, fixing the amount at eight thousand seven hundred and ninety-two dollars and seven cents. This was allowed by them in the sum of seven thousand two hundred and fifty-four dollars and eighty-two cents. No objection seems to have been made to this allowance, and we are inclined to accept it as correct. There is also an amount of one thousand seven hundred dollars, which was charged to Wakefield, but which, although received by him, was, at the request of the Terminal Company turned over to the architects. ITis account should be increased to this extent. We have, then, the architect’s allowance for extras, seven thousand two hundred and fifty-four dollars and eighty-two cents; the balance due under the original contract, eight thousand five hundred and twenty-one dollars and five cents; and the amount of one thousand seven hundred dollars spoken of above; making a total of seventeen thousand four hundred and seventy-five dollars and eighty-seven cents. This wé believe to be a correct summary of the items as disclosed in the record. But it is said that Wakefield made other claims against the Terminal Company, the details of which are not given, and that these were taken into consideration by Garret-son when he settled and stated the former’s account. Garretson’s testimony in relation to this so-called settlement is as follows: “After the troubles came on, in justice to local creditors of Wakefield, whose claims were just, I made a settlement with Wakefield. I don’t understand that it in any way affects these first mortgage bondholders. It was a question of policy as to the best thing to do-, as the second mortgage bondholders, represented by the Credits people,, were going to ask favors, — bridge tax and so on. * * We didn’t go- into the matter of how much was actually due-him on the contract. The object and purpose of this settlement was to protect these lienholders as against the second *578mortgage, believing that it would ultimately come out of the second mortgage bondholders, who would be interested in the construction of the bridge and other things here, and could well afford to have this straightened to- secure the support of all the people in that matter.” It will be seen that this witness testifies in effect that, without regard to the amount actually due Wakefield, he allowed his claim in a sum sufficient to- pay all the subcontractors who were home creditors, expecting in the end to extort reimbursement from the second mortgagees. This alleged settlement is questioned by the Trust Company. Wakefield, in his petition, alleges that there is now due him, “by agreement and final settlement, an unpaid balance of $51,010.84.” This is met by a general denial on the part of the Trust Company. The point is now made by counsel for Wakefield that under these pleadings the Trust Company cannot attack the settlement; that the ground of complaint is fraud, and this must be averred in order to be proved. Under this general denial, we are clear the way is open to show want of authority in Garretson to bind the Terminal Company. Gilbert v. Baxter, 71 Iowa, 327. We may concede Garret-son’s authority, as its president and general manager, to bind the Terminal Company by an agreement of settlement, when entered into in good faith. But this transaction was something more than a settlement, and it can hardly be said to have been made in good faith by him. It was a deliberate attempt to make a gift to home creditors, not of the Terminal Company’s money (that would have been questionable enough), but of the money of the second mortgagees. If the Terminal Company had attempted to give Garretson express authority to carry out such a scheme, it could not legally have done so. Certainly, we shall not find, as we are asked to do> that his authority to so act is implied from his office and the nature of his employment. But, if we adopt the theory that the alleged settlement is attacked on the ground of fraud, we do' not see that the position assumed by Wakefield on this issue of the case can be sus*579tained. Garretson’s testimony, upon which alone the Trust Company relies to defeat this settlement, was received without objection. The answer of the Trust Company contained only a general denial, and, conceding that upon objection this evidence could have been excluded on the ground that fraud was not pleaded, yet we think that a failure to SO' object waives all right to now claim that the court should not consider the issue. Logically, under a general denial of a settlement any evidence should be receivable'which tends to- show that no valid settlement was made. This testimony was certainly in point. If not admissible, it was only because of the formal rules of pleading. These may be waived. Under our practice, by failing to object in a timely and proper manner one may lose his right to insist that a pleading does not state a cause of action. Code 1873, section 2650; Linden v. Green, 81 Iowa, 365. In Mitchell v. Joyce, 76 Iowa, 449, defendant pleaded in a counterclaim matter which could not be properly set up in that manner. Evidence to sustain it was received without objection. Held, that such issue was rightfully in the case. Under the general issue a defendant introduced, without objection, evidence of a defense that could be properly offered only under a special notice attached to the plea. It was held that objection, not having been made in the court below, was to be dfeemed waived. Frankel v. Coots, 41 Mich. 75 (1 N. W. Rep. 940). The court in this case says: “One objection taken in this court for the first time would clearly have been good, if presented in the court below. The defendant seized and justified taking the property upon process against the assignor in favor of his creditors. The plea was that of a general issue only. There should have been a notice attached to the plea. Had this objection been taken in the court below, an amendment would undoubtedly have been permitted upon terms. When the parties do not think proper to raise such an objection, but proceed to and do try the case upon its merits, as though such notice had been given, we think they cannot raise the *580question in this court. It may fairly be said that they have-waived it.” See, also, Bank v. Boesch, 90 Iowa, 47; Isaacson v. Railway Co. 27 Minn. 463 (8 N. W. Rep. 600); Marshuetz v. Wright, 30 Wis. 175 (6 N. W. Rep. 511); Bowers v. Thomas 62 Wis. 480 (22 N. W. Rep. 710); Erickson Fisher, 51 Minn. 300 (53 N. W. Rep. 638). As is held in-this last case, where no objection is made to- the introduction of evidence relating to an issue not presented by the pleadings, it amounts to a consent to try such issue. It is true, Wakefield claims that prior to this settlement he had made various demands for large amounts against the Terminal Company, and that these claims had been previously canvassed and considered, and that they formed the basis of the agreement with Garretson. But, after careful consideration of all the testimony, we are led to believe that the agreement was brought about by the inducements mentioned by Garret-son, and by these alone. The right of the Trust Company to attack this settlement is questioned on another ground. It is said that, so long as the settlement is not objected to by the Terminal Company, its creditors cannot be heard to complain. It is doubtless true that general creditors of the Terminal Company could not complain of the amount of the liability which it chose to confess ; But the mortgagee stands in a different position. lie certainly has a right to question any action of the mortgagor which tends to illegally impair his security. Here was a deliberate attempt on the part of the mortgagor and a lienholder who» claims superior rights in the mortgaged property, to unwarrantably and unlawfully increase the latter;s claim to the-prejudice of the Trust Company. Any person who ha® acquired from another an estate has a right to protect it against burdens that are sought to be unlawfully imposed; upon it by the grantor. Des Moines Mfg. & Supply Co. v. Tilford Milling Co. 9 S. D. 542 (70 N. W. Rep. 839).
*5817 *580III. Next, as to the question of priority. We cannot follow counsel -in their discussion of this branch of the case *581without unwarrantably lengthening this opinion. We think the Terminal Company was a railroad corporation, within the meaning of the statute, and that the building of the union depot was the central thought and purpose of its organization. It was an essential part of the improvement, contemplated from the beginning. This being true, work done upon the building was work done upon the railroad; and the right to a mechanic’s lien for such work dates from the beginning of the improvement, and is against the whole road. Neilson v. Railway Co. 44 Iowa, 71; Brooks v. Railway Co. 101 U. S. 443; Meyer v. Hornby, 101 U. S. 728. The articles of incorporation of the Terminal Company provide that it may also construct warehouses, etc.; and it is argued here by counsel for the Trust Company that, if the depot is to be considered a part of the railway, so may any warehouse that may be constructed in the future. It is said that it would be manifestly unjust to give a lien superior to the mortgage to á laborer or material man who might do work or furnish material for a shed or warehouse that is hereafter erected. The distinction is this: No particular shed or warehouse was in contemplation at the time of the incorporation of the company. Any such building that might be erected would only be an incident of the work. But the depot was, according to all the evidence, an integral part of the undertaking, and the purpose to construct it was in mind from the beginning, and known to all parties. The mortgage in question bears date January 1, 1890. We find as a matter of fact that the work was begun on the Terminal Company’s property for the carrying out of its plan of improvements prior to that date. Wakefield’s lien for the amount we have stated is prior and superior to the lien of the Trust Company.
IV. The Credits Commutation'Company and E. IT. Hubbard, as a grantee in trust of the Terminal Company, and as assignee of the-ITnion Loan & Trust Company, file a cross petition in which they attack the validity of the mortgage *582made to> the Trust Company of North America, on various, grounds, which will be mentioned hereafter. The Union Loan & Trust Company was a second mortgagee of the Terminal property; holding, by express stipulation, subject to the mortgage of the Trust Company of North America. The Credits Commutation Company was the holder of a considerable floating indebtedness of the Terminal Company. No foreclosure of either of the mortgages is sought in this, action. As a matter of fact, foreclosure proceedings under the mortgage of the Trust Company of North America are pending in the federal court, and the Credits Commutation Company, the Terminal Company, and the Union Loan & Trust Company are parties thei’eto-, and have set up there the same matters they are now urging here. That case has been tried in the federal circuit court and in the circuit court of appeals, and in both instances the holding was in favor of the validity and priority of the mortgage of the Trust Company of North America. (69 Fed. Rep. 441; 27 C. C. A. 73, 82 Fed. Rep. 124). All that is asked in this case by thei’ cross petitioners who complain is that their claims be declared valid, and that the first mortgage be held invalid. We might with propriety leave these matters for settlement by the tribunal that has jurisdiction of the foreclosure, were it not for the fact that Wakefield urges the same claim in his behalf. As we permit the Trust Company bo question Wake-field’s settlement with Garretson only on the ground of its interest in the Terminal property, it becomes necessary, when that interest is denied, to determine whether the Trust Company has a mortgage.
8 Y. It is contended that the mortgage is void, first, because the Terminal Company had no legal right or power to make a mortgage; and in this connection we may also consider the claims made, that it had not the power to-mortgage its franchise, or to. give a lien on after-acquired property. The Terminal Company was, as already said, a’railroad company. That it was something *583more, we readily concede, but it was nothing less. Being such, it had the power, expressly given in section 1965, McClain’s Code, to mortgage its property, including its franchise. Section 1966 of said Code gives express authority to mortgage after-acquired property, and we may add that, when the power to mortgage exists, the right to- incumber after-acquired property is necessarily included. Such a mortgage is valid in equity by way of estoppel on the mortgagor and all persons claiming under him, whether voluntarily or otherwise. Mitchell v. Winslow, 2 Story, 630, Fed. Cas. No. 9,673; Christy v. Dana, 34 Cal. 548; Pennock v. Coe, 23 How. 117; 1 Jones, Mortgages 152, and cases cited.
9 VI. It is next urged that the mortgage in question is invalid because the debt it secures is in excess of the amount of indebtedness which the Terminal Company was legally empowered to incur. The capital stock of the company was one million dollars. We take it that "it is only the excess over two-thirds of this sum that can be questioned. Section 1061, Code 1873, limits the amount of indebtedness of corporations formed for pecuniary profit to two-thirds of the capital stock. By Twentieth General Assembly, chapter 22, this section was amended by adding the following proviso-: "Provided, that the provisions of this section shall not apply to- the bonds or other railway securities to be hereafter issued or guaranteed by railway companies of'this state, in aid of the location, construction and equipment of railways, to- the amount of not exceeding sixteen thousand dollars per mile of single track, narrow gauge, lines of road for each mile of railway actually constructed and equipped.” Twenty-first General Assembly, chapter 57, added another proviso, in these words: "Provided, further, that the provisions of this section shall not apply to- the debentures or bonds o-f any company, duly incorporated under the provisions of this chapter, the payment of which debentures or bonds shall be secured by an actual transfer of real estate securities for the benefit and protection of *584purchasers of said debentures or bonds, such securities to be at least equal in amount to the par value of such bonds or debentures, and to be first liens upon unencumbered real estate worth at least twice the amount loaned thereon.” The amount of indebtedness here is largely in excess of twoThirds of the amount of the capital stock, but it is thought by counsel for the Trust Company that the transaction falls within the terms of the last proviso quoted, and that the indebtedness is therefore sanctioned by law. This was the holding of the federal circuit court on the first trial of the foreclosure proceeding. First Nat. Bank of Montpelier v. Sioux City Terminal R. & W. Co. 69 Fed. Rep. 441. We are inclined to think the property mortgaged was at the time the indebtedness was incurred and the mortgage executed, worth double the amount of the debt, but we cannot agree that a mortgage given by a debtor corporation on its own property was intended to be covered by this proviso. It is a matter of public knowledge that within a comparatively late period many companies engaged in the business of making loans on real-estate security have adopted a method of procuring funds to invest, by which they issue their own bonds or debentures, which are placed in the hands of a trustee for sale, and which are secured by real-estate mortgages taken by such companies for other loans which they have made. For something on this subject, see 2 Cook Stock, Stockh. & Corporation Law, section 777. At about the time of the enactment of this amendment, companies were operating extensively in Iowa on this system. The amount of indebtedness, where this manner of business was carefully and honestly done, could not, under ordinary circumstances, prejudice any person interested in the corporation; and we can see good reason for taking such companies out from under the restriction of the original section. We think this proviso applies to a class, and not to a condition; that it singles out this particular kind of corporation, and is not meant to point’out a state of affairs which it was thought might exist with any corporation.
*58510 A^II. Tbe indebtedness for wbicb this mortgage was given being in excess of the amount fixed by law, it remains to be seen whether complainants have any standing to attack the validity of the transaction. The rights of all these cross petitioners accrued subsequent to the making and recording of this mortgage. AVhileAVakefield’s lien, in part, is given priority over the mortgage, his contract was made and his work was done after the mortgage was made and with full notice of it. The other complainants are the holders of an indebtedness that was incurred also in violation of the statute. The Terminal Company, which joins in the attack, has received,, and still retains, the benefit of the funds obtained on this’mortgage. The circuit court of appeals, on appeal from the federal circuit court of the case between these parties, and which may be found in 82 Fed. Rep. 124, affirmed the lower co-urt, but rested its holding upon the ground that complainants could not be heard to assert the invalidity of the Trust Company’s mortgage. The general rule, as stated in Twiss v. Association, 87 Iowa, 733, 737, is that “where an ultra vires contract is made, and performed on one side, the other party cannot be permitted to enjoy the benefits received, but will be required in a proper action to account; in other words, the doctrine of a want of power to contract cannot be invoked to ajd a party to perpetrate a wrong and injustice.” To like effect are the cases of Garrett v. Plow Co. 70 Iowa, 697; Warfield v. Canning Co. 72, Iowa, 666; Humphrey v. Association, 50 Iowa, 607. In Sedgwick on Statutory Construction, 73, it is said: “AYhen it is a simple question of authority to contract, arising either on a question of irregularity. of organization, or of power conferred by its charter, a party who has' had the benefit of the agreement cannot be permitted, in an action founded upon it, to question its validity. It would be in the highest degree inequitable and unjust to permit a defendant to repudiate a contract, the benefit of which he retains.” This language is quoted with approval in Pine Grove Tp. v. Talcott, 19 Wall. *586666, and also in Bank v. Matthews, 98 U. S. 621. In Poole v. Association, 30 Fed. Rep. 513, the same doctrine was applied to a case where the contract made was in excess of an express statutory grant of power. So, too, in Fritts v. Palmer, 132 U. S. 282 (10 Sup. Ct. Rep. 93); Bank v. Matthews, supra; and Manchester & L. R. Co. v. Concord R. Co. 66 N. H. 100 (20 Atl. Rep. 383). In this last case the following statement of the laAV by a learned text writer is approved: “If an agreement is legally void and. unenforceable by reason of some statutory or common-law prohibition, either party to the agreement, who has received anything from the other party, and has failed to perform the agreement on his part, must account to the latter for what he has received. Under these circumstances the courts will grant relief irrespective of the invalid agreement-, unless it involves some positive immorality, or there are other reasons of public policy why the courts should refuse to grant relief in the case.” See, also, on this subject, Wood v. Waterworks Co. 44 Fed. Rep. 146; Central Trust Co. v. Ohio Central Ry. Co. 23 Fed. Rep. 306; Planters' Bank v. Union Bank, 16 Wall. 483; Gold-Mining Co. v. National Bank, 96 U. S. 640; White v. Bank, 22 Pick. 181; Whitney v. Peay, 24 Ark. 22; Whitney-Arms Co. v. Barlow, 63 N. Y. 62; McCarthy v. Lavasche, 89 Ill. 270; Prairie Lodge v. Smith, 58 Miss. 301; Oil Creek & A. R. R. Co. v. Pennsylvania Transp. Co. 83 Pa. St. 160; Madison Avenue Baptist Church v. Baptist Church in Oliver Street, 73 N. Y. 82; Central Trust Co. v. Ohio Central Ry. Co. 23 Fed. Rep. 306; Campbell v. Aryenta Co. 51 Fed. Rep. 1. A distinction is to be taken between contracts like this and those which, independent of statute*, are in violation of public policy. The creation of this indebtedness involved no moral turpitude. The making of the mortgage did not disable the corporation from performing its duties to the public. The Terminal Company had a right to incur a debt, and to execute a mortgage to secure it. The only ground of complaint is that it went further than the *587Irav permitted. Of this the state may complain, but the Terminal Company cannot; nor can any person whose rights are derived through the Terminal Company, and who acquired such rights with knowledge of the mortgage lien. Oil Creek Co. v. Transportation Co., supra; Union Water Co. v. Murphy's Flat Fluming Co. 22 Cal. 620. It will not do to say that the lien should be held invalid, but that the Trust Company may have an action for its debt, as for money had and received. Such a right is of no value now. The Terminal Company should make restitution before it has standing to complain. It is not enough for it to- say that it is insolvent, and cannot repay what it has received, but that it will submit to an action on the part of the Trust Company. We are aware that the security has been held invalid, and a right of recovery thereon denied, in many cases where an action has been permitted upon the common counts. But we think these cases will be found to involve contracts which were absolutely void, and not, as in the case at bar, voidable only. This distinction is clearly preserved in the cases. In Garret v. Plow Co., supra, the indebtedness exceeded the charter limit of the corporation, and the creditors had notice thereof when the transaction took place; and yet a right of recovery was allowed, and the lien of a mortgage upheld. See, also, Warfield v. Canning Co., supra; Jones Mortgages, section 127; Morawetz Private Corporation, 714, 716; Allis v. Jones, 45 Fed. Rep. 148, and cases therein cited. A sound basis appears to exist for this holding. It is the debt which is prohibited, and not the mortgage. So long as the debt in any form can be enforced, the mortgage should stand.
11 VIII. It is said that the Terminal Company, being a railroad corporation, was quasi public in character, and that the rule stated, which applies to1 private corporations, should not obtain as against it. It is true that a railroad eorporation has a dual character, that in many respects it is of a public nature, and that the courts will not enforce against such a corporation a-contract which will dis*588able it from performing its duties to the government or the people. Central Transp. Co. v. Pullman's Palace Car Co. 139 U. S. 24 (11 Sup. Ct. Rep. 478). But we repeat that this mortgage bas no such effect. On the other hand, a railroad company is in many respects a purely private corporation. It is organized in this state under the same section of the Oode which provides for the incorporation of all other companies for pecuniary profit. The restriction as to indebtedness applies to all corporations organized under this section. Under ordinary circumstances, we see no reason for distinguishing between them. It is said further that the plea of estoppel can be urged only in favor of the innocent, and that the bondholders here are not of that class, for they are held to notice of the corporate power of the Terminal Company. This rule has been applied in cases where the act done was wholly void because of an absolute want of power to sustain it, and in cases where considerations of public policy intervened. Here, as repeatedly said, the act is voidable only. The statute does not even impose a penalty therefor. The purpose of the law is to protect stockholders against the acts of reckless or dishonest officials of the corporation. In the present instance the stockholders of the Terminal Company are in nowise injured, for, so far as the record discloses, they had the benefit of all the money raised on this mortgage. There is no demand of public policy that this transaction be held invalid. Many of the cases cited above, in which it is held that the plea of estoppel will lie, are similar to the case at bar in this: that upon its face the act done was in excess of the charter power. See, also, on this point, Matt v. Society, 70 Iowa, 455; Wright v. Pipe-Line Co. 101 Pa. St. 204; Witter v. Mill Co. 78 Wis. 543 (47 N. W. Rep. 729); Carson City Savings Bank v. Carson City Elevator Co., 90 Mich. 350 (51 N. W. Rep. 641); Dewey v. Railway Co. 91 Mich. 351 (51 N. W. Rep. 1063), and cases cited. In this last case the rule as laid down by Morawetz in his work on Corporations (section 684) is stated and adopted. *589That rule is as follows: “It does not follow, because the exercise of certain corporate powers is prohibited by the common law, any corporate act performed in violation of this prohibition will not be recognized by the law as a corporate act. * * * The prohibition of the common law against the unauthorized exercise of corporate power is based upon the ground of public policy alone, and the effect of this pro*hibition should be determined by the requirements of public policy; and, after a contract made by a corporation in excess of its powers is wholly performed by either party, * * * it cannot be said to be in the interest of public policy to deny the innocent party relief. * * * General statutory prohibitions against any corporate act not included in the powers conferred by the charter do nothing more than declare the common law of prohibition against any exercise of corporate powers which has not been authorized by the legislature, and the common-law rule would prevail.” It will be observed that in this case the doctrine stated is applied against a railway company, and in favor of a creditor, who, as cross petitioners say, was charged with notice of its charter power. We might cite many other cases of like character, but it seems needless. The conclusion we have reached on this point, after an examination of numerous authorities, is that the creditor is to be deemed “innocent” whenever the transaction involves no moral wrong on his part, and can be carried out without contravening any requirement of public policy. The circuit court of appeals, passing upon this issue in the action between these parties, said: “Nor is the innocence or ignorance of the creditor essential to the maintenance of his suit to enforce such* a contract. * * .* These decisions do not rest upon the principle of 'estoppel, nor depend upon the creditor’s ignorance of the excessive indebtedness. They stand upon the rule that he who seeks equity must do equity; and upon the principle that he may not at the same time accept the benefits and repudiate the burdens of his contract.” We take this rule to be correct, *590but we conceive it to be only an indirect assertion of the doctrine of estoppel. All parties wlm join here in the attack on this mortgage have been benefited by the transaction for, as we have said, the funds secured thereby were used to improve the property upon which they have their liens, or against which they make their claims. We think the plea of estoppel is good against the Terminal Company and those claiming under it; but whether we rest the holding in terms upon this ground or upon the general equitable principle stated by the federal court, the result is the same: The cross petitioners have no standing to object to the bonds or mortgage of the. Trust. Company.
12 IX. Another point urged against the mortgage is that the instrument as executed was materially different from the form approved by the board of directors of the Terminal Company. As we have seen, the Terminal Company negotiated the bonds secured by this mortgage, and received and appropriated the funds derived from their sale. Under these circumstances, it is in no situation now to complain of the terms and conditions of the mortgage. That instrument, if not originally authorized, has been ratified. Jones Mortgages, section 127; Hotel Co. v. Wade, 97 U. S. 13; McCurdy’s Appeal, 65 Pa. St. 290; Aurora Agricultural Society v. Horticultural Society, 80 Ill. 263.
X. These are the controlling points in the case: Some other questions are discussed by counsel, but we do not deem it necessary that they be specially noticed.
XI. Our conclusion upon the whole case is that the Gillette-Herzog Company should have a lien as allowed by the trial court, but that it should rank eleventh in order of priority as the claims are numbered in the decree, and it should have no personal judgment against Wakefield; that Wakefield is entitled to a judgment and lien, as against the Terminal Company, for the sum awarded by the district court, but that only the amount of seventeen thousand four hundred and seventy-five dollars and eighty-seven cents, with *591proportionate interest, should-be established as superior to the mortgage of the Trust Company of North America. With these modifications, the decree of the district court is AEEIRMED.
On Rehearing Tuesday, February 7, 1899. — Modified.
Waterman, J.
A vigorous assault was made upon the foregoing opinion, in an application for a rehearing, by most of the numerous parties interested. While we do not think it necessary to reopen the case, we have concluded to make certain modifications in the holdings first announced. In the original opinion, the Gillette-TIerzog Company was advanced from the thirteenth to the eleventh place in the list of mechanic’s lien claimants as fixed by the district court. We conclude, upon consideration, that the change was not warranted. The lien is, therefore, reinstated in the place from which we attempted to take it.
13 II. Next, as to the amount due Wakefield, which was .allowed precedence over the mortgage of the Trust Company of North America. This we fixed at seventeen thousand four hundred and seventy-five dollars and eighty-seven cents. In the reply of the trust company named there is an admission of nineteen thousand and six dollars and fifty-one cents as due Wakefield under his contract and for extras. It is 'claimed by the trust company that this amount was inadvertently stated, through an error in writing the figures. We may say further, as to this matter, that this admission, though mentioned in the statement of the case by the opposing parties, was not insisted upon in argument. Wakefield, and those claiming under him, relied wholly, in their discussion of the case, upon the settlement with Garretson,. and insisted upon their right to the amount therein allowed. But, notwithstanding these facts, we think they are entitled to the benefit of the admission. This amount, added to the one thousand seven hundred dollar item spoken of in the former opinion, would make the sum of twenty thousand seven hundred and *592six dollars and fifty-one cents due Wakefield from the terminal company, which should have priority over the mortgage of the Trust Company of North America.
14 III. These are the corrections which we think proper to make. There is, however, another matter of which it is well to speak, now that we have the case again under consideration. Under Wakefield’s contract the terminal company was obliged to" reserve fifteen per cent, of the amount due him until the completion of his contract, and it is strenuously claimed that this sum — about fifteen thousand eight hundred and seventy-five dollars and fifty-eight cents — should be added to the amount we have found to be due him. In making this claim on behalf of the mechanic’s lien claimants, another clause of the contract is wholly overlooked. That instrument provided that if Wake-field failed to complete the work, the terminal company might do so and deduct the cost thereof from the amount due him. This contingency occurred. Wakefield failed in his contract. The terminal company assumed the work and completed the building at a cost in excess of the fifteen per cent, reserve. It had a legal right to draw upon the reserve for this purpose, and, having exhausted it, can m> more be compelled to account for it to Wakefield’s creditors than to Wakefield if he were seeking a recovery on the contract. The terminal company acted strictly according to its contract, and this it had a right to do'. Epeneter v. Montgomery Co. 98 Iowa, 159, and cases cited.
Some other matters were pressed by counsel on the application for rehearing, but, as they were urged then for the first time, not having been noticed on the original submission, we can give them no consideration. With the modifications stated, the original opinion will stand.