Currently there are 3 places where it makes sense to retain a wallet shared pointer:
vpwallets;interfaces::Walletinterface instance - used by the UI;- wallet RPC functions - given by
GetWalletForJSONRPCRequest.
The way it is now it is possible to have, for instance, listunspent RPC and in parallel unload the wallet (once #13111 is merged) without blocking. Once the RPC finishes, the shared pointer will release the wallet.
It is also possible to get all existing wallets without blocking because the caller keeps a local list of shared pointers.
This is mostly relevant for wallet unloading.
This PR replaces #11402.