wallet: Make vpwallets usage thread safe
Summary:
This PR turns the functions introduced in #13017 thread safe. This is
required to correctly support dynamically loading wallets, which is
implemented in #10740.
Backport of core PR13028
https://github.com/bitcoin/bitcoin/pull/13028/files
Test Plan:
make check ./test/functional/test_runner.py wallet_*
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D3631