This is a small step towards better multi wallet management. Starts by removing the global vpwallets
and adding an interface to add/remove/retrieve wallets.
The way it is now it is possible to have, for instance, listunspent
RPC and in parallel unload the wallet (once #10740 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.
I would like to include either here or in follow ups:
- kind of
WalletManager
class; - keep a weak pointer so when the app terminates it is possible to gracefully unload the wallet;
- make the new interface thread safe.
Please consider this RFC.