<!-- Describe the issue -->

When trying to sign a transaction in a encrypted wallet that is locked, version 0.16 would return the following error:

```"Please enter the wallet passphrase with walletpassphrase first."```

While doing exactly the same procedure against 0.17, the response is something like:

```json
"hex": "020000000183ac9cc1137c444f32356fb070ecba194c87a05e43674c06a55f5b1d0561eabc0000000000ffffffff0180626a94000000001600141875aa6ab19c2551c11759cf3e9f4dd7aa40bcf500000000",
       "complete": false,
       "errors": [
         {
           "txid": "bcea61051d5b5fa5064c67435ea0874c19baec70b06f35324f447c13c19cac83",
           "vout": 0,
           "witness": [
           ],
           "scriptSig": "",
           "sequence": 4294967295,
           "error": "Unable to sign input, invalid stack size (possibly missing key)"
         }
     ]

```

<!--- What behavior did you expect? -->

v0.17 should check if the wallet is locked before trying to sign the tx and return the same error as v0.16 for consistency reasons.
ListTransactions(pwallet, tx, 0, true, transactions, filter);
        }
    }
    
    
    UniValue removed(UniValue::VARR);
    while (include_removed && paltindex && paltindex != pindex) {
        CBlock block;
        if (!ReadBlockFromDisk(block, paltindex, Params().GetConsensus())) {
            throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
        }
        for (const CTransactionRef& tx : block.vtx) {
            auto it = pwallet->mapWallet.find(tx->GetHash());
            if (it != pwallet->mapWallet.end()) {
                
                
                ListTransactions(pwallet, it->second, -100000000, true, removed, filter);
            }
        }
        paltindex = paltindex->pprev;
    }
    CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms];
    uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256();
    UniValue ret(UniValue::VOBJ);
    ret.pushKV("transactions", transactions);
    if (include_removed) ret.pushKV("removed", removed);
    ret.pushKV("lastblock", lastblock.GetHex());
    return ret;
}
static UniValue gettransaction(const JSONRPCRequest& request)