When using the `rescanblockchain` wallet RPC command, it seems like sometimes (though not always, and I couldn't find a specific pattern for when this does and doesn't happen) the `time` field of all transactions found is being set to the time of the most recent transaction detected. Besides that field, all data (including block and blocktime) return correctly. What's more, even in a node with `txindex=1` this happens, despite that when calling the (non-wallet-specific) `getrawtransaction` command, it returns the correct time.

Here's an example of a testnet transaction where I experienced this behaviour, and the output of Core where the same `txid` has. 2 different `time`s - a correct one using `getrawtransaction` and an incorrect one using `gettransaction`:
```
bitcoin-cli --testnet -rpcwallet=wallet getrawtransaction 8bacfc9c63d181e9d303f57f550fe72870afd640c961466829c6212bb23a72fe 1
{
  "txid": "8bacfc9c63d181e9d303f57f550fe72870afd640c961466829c6212bb23a72fe",
  "hash": "3de22064b8fec52fb183a8ad46fd011e6c6cab9906a008afa3d649d11bd250f1",
  "version": 2,
  "size": 222,
  "vsize": 141,
  "weight": 561,
  "locktime": 0,
  "vin": [
    {
      "txid": "685571776adce2ac3332faf6ed125235366cc3cb464604c9234bf371f1ab4e02",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "30440220516d0b313aae44f639a111dac8f27bc1fac446345aaad51852a784620ac62c690220433cb7fdeb78cd84574ec0ddd08789a248fe19b71759e1b3b448ff9c3f980be401",
        "03eca8ceb44c4d930ab89fb5d721d02a745e4aeb0f75993fa535e98fb6c7f6e16e"
      ],
      "sequence": 4294967294
    }
  ],
  "vout": [
    {
      "value": 0.53891045,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 f3020d45a9ccf870ddf4176fde4420931ffd9af6",
        "hex": "0014f3020d45a9ccf870ddf4176fde4420931ffd9af6",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "tb1q7vpq63dfenu8ph05zahau3pqjv0lmxhk73dsjm"
        ]
      }
    },
    {
      "value": 0.10000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 bf702bf755da860153e7b1043fea160c6dcd9f1a",
        "hex": "0014bf702bf755da860153e7b1043fea160c6dcd9f1a",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "tb1qhaczha64m2rqz5l8kyzrl6skp3kum8c6m0c2h4"
        ]
      }
    }
  ],
  "hex": "02000000000101024eabf171f34b23c9044646cbc36c36355212edf6fa3233ace2dc6a777155680000000000feffffff02e54f360300000000160014f3020d45a9ccf870ddf4176fde4420931ffd9af68096980000000000160014bf702bf755da860153e7b1043fea160c6dcd9f1a024730440220516d0b313aae44f639a111dac8f27bc1fac446345aaad51852a784620ac62c690220433cb7fdeb78cd84574ec0ddd08789a248fe19b71759e1b3b448ff9c3f980be4012103eca8ceb44c4d930ab89fb5d721d02a745e4aeb0f75993fa535e98fb6c7f6e16e00000000",
  "blockhash": "00000000000000bc3b97cbe323c4695f39a65cc1d73060dca8ad084fb0ce61b5",
  "confirmations": 27528,
  "time": 1600623861,
  "blocktime": 1600623861
}
```
```
bitcoin-cli --testnet -rpcwallet=wallet gettransaction 8bacfc9c63d181e9d303f57f550fe72870afd640c961466829c6212bb23a72fe
{
  "amount": -0.10000000,
  "fee": -0.00000142,
  "confirmations": 27528,
  "blockhash": "00000000000000bc3b97cbe323c4695f39a65cc1d73060dca8ad084fb0ce61b5",
  "blockheight": 1835261,
  "blockindex": 24,
  "blocktime": 1600623861,
  "txid": "8bacfc9c63d181e9d303f57f550fe72870afd640c961466829c6212bb23a72fe",
  "walletconflicts": [
  ],
  "time": 1601486746,
  "timereceived": 1602570577,
  "bip125-replaceable": "no",
  "details": [
    {
      "involvesWatchonly": true,
      "address": "tb1q7vpq63dfenu8ph05zahau3pqjv0lmxhk73dsjm",
      "category": "send",
      "amount": -0.53891045,
      "label": "Change #5",
      "vout": 0,
      "fee": -0.00000142,
      "abandoned": false
    },
    {
      "involvesWatchonly": true,
      "address": "tb1qhaczha64m2rqz5l8kyzrl6skp3kum8c6m0c2h4",
      "category": "send",
      "amount": -0.10000000,
      "vout": 1,
      "fee": -0.00000142,
      "abandoned": false
    },
    {
      "involvesWatchonly": true,
      "address": "tb1q7vpq63dfenu8ph05zahau3pqjv0lmxhk73dsjm",
      "category": "receive",
      "amount": 0.53891045,
      "label": "Change #5",
      "vout": 0
    }
  ],
  "hex": "02000000000101024eabf171f34b23c9044646cbc36c36355212edf6fa3233ace2dc6a777155680000000000feffffff02e54f360300000000160014f3020d45a9ccf870ddf4176fde4420931ffd9af68096980000000000160014bf702bf755da860153e7b1043fea160c6dcd9f1a024730440220516d0b313aae44f639a111dac8f27bc1fac446345aaad51852a784620ac62c690220433cb7fdeb78cd84574ec0ddd08789a248fe19b71759e1b3b448ff9c3f980be4012103eca8ceb44c4d930ab89fb5d721d02a745e4aeb0f75993fa535e98fb6c7f6e16e00000000"
}
```
std::shared_ptr<CWallet> LoadWallet(WalletContext& context, const std::string& name, std::optional<bool> load_on_start, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string& name, std::optional<bool> load_on_start, DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
std::unique_ptr<interfaces::Handler> HandleLoadWallet(WalletContext& context, LoadWalletFn load_wallet);
std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
constexpr CAmount DEFAULT_PAY_TX_FEE = 0;
static const CAmount DEFAULT_FALLBACK_FEE = 0;
static const CAmount DEFAULT_DISCARD_FEE = 10000;
static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
static const CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; 
/**
 * maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled by default
 *
 * A value of -1 disables this feature completely.
 * A value of 0 (current default) means to attempt to do partial spend avoidance, and use its results if the fees remain *unchanged*
 * A value > 0 means to do partial spend avoidance if the fee difference against a regular coin selection instance is in the range [0..value].
 */
static const CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE = 0;
constexpr CAmount HIGH_APS_FEE{COIN / 10000};
static const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000;
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
static const bool DEFAULT_WALLET_RBF = false;
static const bool DEFAULT_WALLETBROADCAST = true;
static const bool DEFAULT_DISABLE_WALLET = false;
constexpr CAmount DEFAULT_TRANSACTION_MAXFEE{COIN / 10};
constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB};
static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
class CCoinControl;