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{"fundrawtransaction",
                "\nIf the transaction has no inputs, they will be automatically selected to meet its out value.\n"
                "It will add at most one change output to the outputs.\n"
                "No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n"
                "Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n"
                "The inputs added will not be signed, use signrawtransactionwithkey\n"
                " or signrawtransactionwithwallet for that.\n"
                "Note that all existing inputs must have their previous output transaction be in the wallet.\n"
                "Note that all inputs selected must be of standard form and P2SH scripts must be\n"
                "in the wallet using importaddress or addmultisigaddress (to calculate fees).\n"
                "You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n"
                "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n",
                {
                    {"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"},
                    {"options", RPCArg::Type::OBJ, RPCArg::Optional::OMITTED_NAMED_ARG, "for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}",
                        {
                            {"add_inputs", RPCArg::Type::BOOL,  "true", "For a transaction with existing inputs, automatically include more if they are not enough."},
                            {"changeAddress", RPCArg::Type::STR,  "pool address", "The bitcoin address to receive the change"},
                            {"changePosition", RPCArg::Type::NUM,  "random", "The index of the change output"},
                            {"change_type", RPCArg::Type::STR,  "set by -changetype", "The output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
                            {"includeWatching", RPCArg::Type::BOOL,  "true for watch-only wallets, otherwise false", "Also select inputs which are watch only.\n"
                                                          "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n"
                                                          "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
                            {"lockUnspents", RPCArg::Type::BOOL,  "false", "Lock selected unspent outputs"},
                            {"fee_rate", RPCArg::Type::AMOUNT,  "not set, fall back to wallet fee estimation", "Specify a fee rate in " + CURRENCY_ATOM + "/vB."},
                            {"feeRate", RPCArg::Type::AMOUNT,  "not set, fall back to wallet fee estimation", "Specify a fee rate in " + CURRENCY_UNIT + "/kvB."},
                            {"subtractFeeFromOutputs", RPCArg::Type::ARR,  "empty array", "The integers.\n"
                                                          "The fee will be equally deducted from the amount of each specified output.\n"
                                                          "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"