mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-21 06:12:30 +02:00
Refactor: Move HavePrivateKeys code out of CWallet::CreateWalletFromFile
This commit does not change behavior.
This commit is contained in:
parent
8b0d82bb42
commit
f45d12b36c
@ -396,6 +396,12 @@ bool LegacyScriptPubKeyMan::Upgrade(int prev_version, std::string& error)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LegacyScriptPubKeyMan::HavePrivateKeys() const
|
||||||
|
{
|
||||||
|
LOCK(cs_KeyStore);
|
||||||
|
return !mapKeys.empty() || !mapCryptedKeys.empty();
|
||||||
|
}
|
||||||
|
|
||||||
static int64_t GetOldestKeyTimeInPool(const std::set<int64_t>& setKeyPool, WalletBatch& batch) {
|
static int64_t GetOldestKeyTimeInPool(const std::set<int64_t>& setKeyPool, WalletBatch& batch) {
|
||||||
if (setKeyPool.empty()) {
|
if (setKeyPool.empty()) {
|
||||||
return GetTime();
|
return GetTime();
|
||||||
|
@ -168,6 +168,8 @@ public:
|
|||||||
/** Upgrades the wallet to the specified version */
|
/** Upgrades the wallet to the specified version */
|
||||||
virtual bool Upgrade(int prev_version, std::string& error) { return false; }
|
virtual bool Upgrade(int prev_version, std::string& error) { return false; }
|
||||||
|
|
||||||
|
virtual bool HavePrivateKeys() const { return false; }
|
||||||
|
|
||||||
virtual int64_t GetOldestKeyPoolTime() { return GetTime(); }
|
virtual int64_t GetOldestKeyPoolTime() { return GetTime(); }
|
||||||
|
|
||||||
virtual size_t KeypoolCountExternalKeys() { return 0; }
|
virtual size_t KeypoolCountExternalKeys() { return 0; }
|
||||||
@ -276,6 +278,8 @@ public:
|
|||||||
|
|
||||||
bool Upgrade(int prev_version, std::string& error) override;
|
bool Upgrade(int prev_version, std::string& error) override;
|
||||||
|
|
||||||
|
bool HavePrivateKeys() const override;
|
||||||
|
|
||||||
int64_t GetOldestKeyPoolTime() override;
|
int64_t GetOldestKeyPoolTime() override;
|
||||||
size_t KeypoolCountExternalKeys() override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
size_t KeypoolCountExternalKeys() override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
|
@ -3648,9 +3648,10 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
|
|||||||
error = strprintf(_("Error loading %s: Private keys can only be disabled during creation").translated, walletFile);
|
error = strprintf(_("Error loading %s: Private keys can only be disabled during creation").translated, walletFile);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (walletInstance->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
|
} else if (walletInstance->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
|
||||||
LOCK(walletInstance->cs_KeyStore);
|
if (walletInstance->m_spk_man) {
|
||||||
if (!walletInstance->mapKeys.empty() || !walletInstance->mapCryptedKeys.empty()) {
|
if (walletInstance->m_spk_man->HavePrivateKeys()) {
|
||||||
warnings.push_back(strprintf(_("Warning: Private keys detected in wallet {%s} with disabled private keys").translated, walletFile));
|
warnings.push_back(strprintf(_("Warning: Private keys detected in wallet {%s} with disabled private keys").translated, walletFile));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user