While working on this PR https://github.com/bitcoin/bitcoin/pull/18570 I ran into a bit confusing situation where in one function a **CWallet reference** was expected while two others dealt with **CWallet pointers**. My initial reaction was: `let's harmonize them by making them references`. However, not being part of the PR itself I did't change anything and completed the PR first.

Now, after having analyzed the `rpcwallet.cpp` code I came to the conclusion that:

* converting them all into references is not the solution as they're originally **shared_ptr**s
* but also: there is no (visible) reason why every RPC function should begin like this:

```cpp
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
const CWallet* const pwallet = wallet.get();
```

This clearly defeats the purpose of shared pointers for no obvious reason. *Maybe I am missing something?*

In my (unpublished) [code changes](https://github.com/brakmic/bitcoin/commit/0b3ee615491edf6f542631bf6ae6f72eac406550) all raw pointers got replaced with **shared_ptr**s but kept their original names (that is, *pwallet*). In the end, they're pointers too, so the most of the original code remained untouched.

However, some of the helper functions couldn't be changed because external code is accessing them and I didn't want to make this task "virulent". So I introduced new ("Ref") variants that expect **shared_ptr** parameters, namely: 

```cpp
void EnsureWalletRefIsUnlocked(const std::shared_ptr<CWallet>);
bool EnsureWalletRefIsAvailable(const std::shared_ptr<CWallet>, bool avoidException);
```

I have tested the code, with python and boost-tests, and could not find any errors. 
But before opening a PR I would like to open a discussion about this. 

Is there any reason to keep on working with raw pointers when every function call actually begins with *shared_ptr*s?

Regards,
{
    return RPCHelpMan{"importdescriptors",
                "\nImport descriptors. This will trigger a rescan of the blockchain based on the earliest timestamp of all descriptors being imported. Requires a new wallet backup.\n"
            "\nNote: This call can take over an hour to complete if using an early timestamp; during that time, other rpc calls\n"
            "may report that the imported keys, addresses or scripts exist but related transactions are still missing.\n",
                {
                    {"requests", RPCArg::Type::ARR, RPCArg::Optional::NO, "Data to be imported",
                        {
                            {"", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED, "",
                                {
                                    {"desc", RPCArg::Type::STR, RPCArg::Optional::NO, "Descriptor to import."},
                                    {"active", RPCArg::Type::BOOL,  "false", "Set this descriptor to be the active descriptor for the corresponding output type/externality"},
                                    {"range", RPCArg::Type::RANGE, RPCArg::Optional::OMITTED, "If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import"},
                                    {"next_index", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "If a ranged descriptor is set to active, this specifies the next index to generate addresses from"},
                                    {"timestamp", RPCArg::Type::NUM, RPCArg::Optional::NO, "Time from which to start rescanning the blockchain for this descriptor, in " + UNIX_EPOCH_TIME + "\n"
        "                                                              Use the string \"now\" to substitute the current synced blockchain time.\n"
        "                                                              \"now\" can be specified to bypass scanning, for outputs which are known to never have been used, and\n"
        "                                                              0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest timestamp\n"
        "                                                              of all descriptors being imported will be scanned.",
                                         "", {"timestamp | \"now\"", "integer / string"}
                                    },
                                    {"internal", RPCArg::Type::BOOL,  "false", "Whether matching outputs should be treated as not incoming payments (e.g. change)"},
                                    {"label", RPCArg::Type::STR,  "''", "Label to assign to the address, only allowed with internal=false"},
                                },
                            },
                        },
                        "\"requests\""},