[backport#17304 16/18] Refactor: Move RewriteDB code out of CWallet
Summary:
This commit does not change behavior.
https://github.com/bitcoin/bitcoin/pull/17304/commits/089e17d45c8147bd0303bcbf02dc0f7d6b387f2a
Depends on D7162
Partial backport of Core PR17304
Test Plan:
ninja check
Reviewers: #bitcoin_abc, jasonbcox
Reviewed By: #bitcoin_abc, jasonbcox
Differential Revision: https://reviews.bitcoinabc.org/D7163