If the owner of any lot shall build a substantial and durable brick or stone wall on the line which divides his lot from another, and the owner or lessee of that other lot should desire to erect an adjoining building and connect the same with the building already erected, so as to make the wall of the former building serve as the wall of his own, he may do so by paying to the owner of the first wall half the value thereof, or half the value of so much of the former wall as he may use as a wall to his own house; but he shall not be at liberty to use the former wall in any way which may prove dangerous or detrimental to the owner, except he may close lights therein.