This is a rebased #18592.
This PR replaces raw pointers in
rpcwallet.cpp
andrpcdump.cpp
with shared_ptr. The motivation for this PR is described here #18590
It seems that this PR is indirectly related to this issue: #13063 (review)
Notice: I have deliberately not changed the class
WalletRescanReserver
whose constructor expects a raw pointer, because it’s external and affects other areas, which I didn’t touch to avoid making this PR “viral”.
Fixes #18590