Section 6. This chapter and chapter one hundred and fifty-nine shall not impair the rights of the commonwealth as asserted or reserved in previous statutes, and the commonwealth may, at any time during the continuance of the charter of a railroad corporation after the expiration of twenty years from the opening of its railroad for use, purchase of the corporation its railroad and all its franchise, property, rights and privileges by paying therefor such amount as will reimburse to it the amount of capital paid in, with a net profit thereon of ten per cent a year from the time of the payment thereof by the stockholders to the time of the purchase.