mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-19 20:20:00 +01:00
wallet: keep track of when the passphrase is needed when rescanning
Wallet passphrases are needed to top up the keypool 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:
- `walletlock`
- `encryptwallet`
- `walletpassphrasechange`
This commit is contained in:
@@ -128,6 +128,10 @@ RPCHelpMan walletpassphrasechange()
|
||||
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called.");
|
||||
}
|
||||
|
||||
if (pwallet->IsScanningWithPassphrase()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before changing the passphrase.");
|
||||
}
|
||||
|
||||
// TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string)
|
||||
// Alternately, find a way to make request.params[0] mlock()'d to begin with.
|
||||
SecureString strOldWalletPass;
|
||||
@@ -181,6 +185,10 @@ RPCHelpMan walletlock()
|
||||
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called.");
|
||||
}
|
||||
|
||||
if (pwallet->IsScanningWithPassphrase()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before locking the wallet.");
|
||||
}
|
||||
|
||||
pwallet->Lock();
|
||||
pwallet->nRelockTime = 0;
|
||||
|
||||
@@ -229,6 +237,10 @@ RPCHelpMan encryptwallet()
|
||||
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called.");
|
||||
}
|
||||
|
||||
if (pwallet->IsScanningWithPassphrase()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before encrypting the wallet.");
|
||||
}
|
||||
|
||||
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
|
||||
// Alternately, find a way to make request.params[0] mlock()'d to begin with.
|
||||
SecureString strWalletPass;
|
||||
|
||||
Reference in New Issue
Block a user