Fix ZapSelectTx to sync wallet spends
Summary:
PR18850:
The motivation is mapWallet is used, in many places, without check (method at expects that hash presents) but that's not exactly true when mapTxSpends and mapWallet are out of sync. That can lead to crash/data loss in wallet.
PR19493 fixes clang build on Mac OS
This is a backport of core#18850 and core#19493
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D9989