wallet: Write best block to disk before backup
Summary:
This ensures that the best block is included in the backup which leads to a more consistent behavior when loading the backup.
This is a partial backport of core#30678
https://github.com/bitcoin/bitcoin/pull/30678/commits/7e3dbe4180cbeb65e59b53d9fa98509e9189549d
https://github.com/bitcoin/bitcoin/pull/30678/commits/037b101e808ccf9e717751619e04f6e87d614efd
Depends on D17907
Test Plan:
ninja all check-all
I also succesfully ran the wallet_assumeutxo.py test on my assumeutxo dev branch
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D17907