Help remembering a book

Hello, I am looking for help remembering the name and author of a book I read about 10 years ago. I don’t think it was a new book then. I grabbed it from my public library. I’m sorry, but I have little to go on (I’d like to re-read the book, which is why I’m asking for this help). I’m hoping it sounds familiar to someone. Here’s what I remember:

The setting was a fictional world, similar to Earth. Technology was at about the same level as ours. The main character was a youth in the beginning of the book, and the book follows his life right up to old age, with particular emphasis on his career. He is an inventor. When the book starts out, he is somewhat defiant of authority. There is a curfew and boundaries, i.e. fence or something. He slips out after curfew, explores the world outside the fence, etc. He is pretty bright, and applies himself to making things like a wireless radio, etc. even when he’s quite young.

Pretty early in the book, an antagonist shows up. I can’t remember where he comes from. I thought it was like the principal of his school or something, but he’s there throughout the book, and I think in later years, he’s like a police inspector or something.

Well, the details are very sketchy in my memory, but I seem to recall this antagonist is always trying to catch our main character red-handed, because he’s always violating some minor law or something. But the main character is not too bothered by the antagonist – he sees him as a minor annoyance, but the main character always manages to be doing something innocent when he is caught, so he’s always off the hook. Or maybe he does get caught a few times but the charges don’t stick or something.

Well, as this main character grows older, his inventions are increasingly more useful to society – in all areas, replacement organs, efficient energy vehicles, etc. He acquires some degree of fame, and maybe the antagonist is trying to thwart him out of jealousy or something.

Up to this point in my re-telling, this could probably describe the plot of a lot of books, but it is the ending which will probably distinguish this book. Furthermore, up to this point, I am sure I took a lot of liberties in adding my own imagination to my recollection of the plot. But I’m pretty sure I have the ending exactly right:

The main character has come up with some inventions that help prolong life, and as he and the antagonist are really up there in years, i.e. bodies failing, not much longer to live, etc., the main character gets in touch with the antagonist, invites him to his laboratory, and wants to talk to him. The antagonist is suspicious, but there is no animosity on the part of the main character. Instead, the main character tells his “life long enemy” about his last invention. It is some kind of tank that he will be submerging himself into, which, when he comes out of it, he will have a youthful, strong body. The main character shows the antagonist that there are actually two such tanks. He asks the antagonist to get into the other one and go through the process with him. Up until this point, the antagonist has avoided using any of this main character’s inventions all throughout his life, even though they are majorly integrated into society, just because of this jealousy, hatred thing he has going on. So he can’t for the life of him understand this offer. He thinks maybe it’s a trick – a way to kill him or something, but they’re both so old, the main character asks him “what would I gain from screwing you over now?”

Well, the antagonist has to know why the main character would give HIM this chance at – well, starting life over again, after all the friction the antagonist has given him through all the years. The main character says something like “what would be the point in going through another 70 or 80 years of life, without you there at every turn trying to thwart my efforts. We’re in this together! We always have been. Don’t you feel the same way?” And with that argument, the antagonist realizes that for both of them, it has turned into a major part of their lives – this battle of wits and being opponents to one another – and he too feels he doesn’t want it to end. As I recall, the very last words of the book are the two of them submerging themselves into these tanks together.

I’m sorry, I don’t remember ANY names of the characters or anything, but hopefully someone recognizes the book from the recollection I’ve given. I don’t believe it was a big name author, and I don’t think the book was part of any series, or had any sequel, though I’m not positive about any of that.

I’m going to post this to several sci-fi message boards, as I really want to try to find this book again; sorry in advance if anyone thinks that’s a no-no. And thanks in advance if you can help!