Wallet passphrases are needed to top up the keypool of encrypted wallets
during a rescan. The following RPCs need the passphrase when rescanning:
- importdescriptors
- rescanblockchain
The following RPCs use the information about whether or not the
passphrase is being used to ensure that full rescans are able to
take place (meaning the following RPCs should not be able to run
if a rescan requiring the wallet to be unlocked is taking place):
- walletlock
- encryptwallet
- walletpassphrasechange
m_relock_mutex
is also introduced so that the passphrase is not
deleted from memory when the timeout provided in
walletpassphrase
is up and the wallet is still rescanning.
Fixes #25702, #11249
Thanks to achow101 for coming up with the idea of using a new mutex to solve this issue and for answering related questions.