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