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{"sendtoaddress",
                "\nSend an amount to a given address." +
        HELP_REQUIRING_PASSPHRASE,
                {
                    {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to send to."},
                    {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The amount in " + CURRENCY_UNIT + " to send. eg 0.1"},
                    {"comment", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "A comment used to store what the transaction is for.\n"
                                         "This is not part of the transaction, just kept in your wallet."},
                    {"comment_to", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "A comment to store the name of the person or organization\n"
                                         "to which you're sending the transaction. This is not part of the \n"
                                         "transaction, just kept in your wallet."},
                    {"subtractfeefromamount", RPCArg::Type::BOOL,  "false", "The fee will be deducted from the amount being sent.\n"
                                         "The recipient will receive less bitcoins than you enter in the amount field."},
                    {"replaceable", RPCArg::Type::BOOL,  "wallet default", "Allow this transaction to be replaced by a transaction with higher fees via BIP 125"},
                    {"conf_target", RPCArg::Type::NUM,  "wallet -txconfirmtarget", "Confirmation target in blocks"},
                    {"estimate_mode", RPCArg::Type::STR,  "unset", std::string() + "The fee estimate mode, must be one of (case insensitive):\n"
            "       \"" + FeeModes("\"\n\"") + "\""},
                    {"avoid_reuse", RPCArg::Type::BOOL,  "true", "(only available if avoid_reuse wallet flag is set) Avoid spending from dirty addresses; addresses are considered\n"
                                         "dirty if they have previously been used in a transaction."},
                    {"fee_rate", RPCArg::Type::AMOUNT,  "not set, fall back to wallet fee estimation", "Specify a fee rate in " + CURRENCY_ATOM + "/vB."},
                    {"verbose", RPCArg::Type::BOOL,  "false", "If true, return extra information about the transaction."},
                },
                {
                    RPCResult{"if verbose is not set or set to false",
                        RPCResult::Type::STR_HEX, "txid", "The transaction id."
                    },
                    RPCResult{"if verbose is set to true",