Merge bitcoin/bitcoin#34147: scripted-diff: refactor: wallet: Delete duplicate IsCrypted()

11ce5cf799 scripted-diff: refactor: wallet: Delete IsCrypted (David Gumberg)

Pull request description:

  This function is a duplicate of `HasEncryptionKeys()`.

ACKs for top commit:
  maflcko:
    review ACK 11ce5cf799 🔀
  billymcbip:
    utACK [11ce5cf](https://github.com/bitcoin/bitcoin/pull/34147/commits/11ce5cf7997e6d09806dd4e73043afa758810856)
  polespinasa:
    code review tACK 11ce5cf799
  rkrux:
    crACK 11ce5cf799

Tree-SHA512: 24bd9fedb17fab092346953558b25a2e4181d8f3750cedd0ecf3939291216190d442a38c93aa6829a3a88e60d94b90cada42136c24fd0fabe367994fc1e89690
This commit is contained in:
merge-script committed 2025-12-27 16:29:58 +00:00
commit c575990651
7 files changed
+15 -21

No files matched your search

+3 -3
View File
@@ -68,9 +68,9 @@ public:
enum EncryptionStatus
{
NoKeys, // wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)
Unencrypted, // !wallet->IsCrypted()
Locked, // wallet->IsCrypted() && wallet->IsLocked()
Unlocked // wallet->IsCrypted() && !wallet->IsLocked()
Unencrypted, // !wallet->HasEncryptionKeys()
Locked, // wallet->HasEncryptionKeys() && wallet->IsLocked()
Unlocked // wallet->HasEncryptionKeys() && !wallet->IsLocked()
};
OptionsModel* getOptionsModel() const;
+2 -2
View File
@@ -140,7 +140,7 @@ public:
{
return m_wallet->EncryptWallet(wallet_passphrase);
}
bool isCrypted() override { return m_wallet->IsCrypted(); }
bool isCrypted() override { return m_wallet->HasEncryptionKeys(); }
bool lock() override { return m_wallet->Lock(); }
bool unlock(const SecureString& wallet_passphrase) override { return m_wallet->Unlock(wallet_passphrase); }
bool isLocked() override { return m_wallet->IsLocked(); }
@@ -623,7 +623,7 @@ public:
{
auto wallets{GetWallets(m_context)};
auto it = std::find_if(wallets.begin(), wallets.end(), [&](std::shared_ptr<CWallet> w){ return w->GetName() == wallet_name; });
if (it != wallets.end()) return (*it)->IsCrypted();
if (it != wallets.end()) return (*it)->HasEncryptionKeys();
// Unloaded wallet, read db
DatabaseOptions options;
+4 -4
View File
@@ -45,7 +45,7 @@ RPCHelpMan walletpassphrase()
{
LOCK(pwallet->cs_wallet);
if (!pwallet->IsCrypted()) {
if (!pwallet->HasEncryptionKeys()) {
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrase was called.");
}
@@ -134,7 +134,7 @@ RPCHelpMan walletpassphrasechange()
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
if (!pwallet) return UniValue::VNULL;
if (!pwallet->IsCrypted()) {
if (!pwallet->HasEncryptionKeys()) {
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called.");
}
@@ -199,7 +199,7 @@ RPCHelpMan walletlock()
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
if (!pwallet) return UniValue::VNULL;
if (!pwallet->IsCrypted()) {
if (!pwallet->HasEncryptionKeys()) {
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called.");
}
@@ -256,7 +256,7 @@ RPCHelpMan encryptwallet()
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: wallet does not contain private keys, nothing to encrypt.");
}
if (pwallet->IsCrypted()) {
if (pwallet->HasEncryptionKeys()) {
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called.");
}
+1 -1
View File
@@ -93,7 +93,7 @@ static RPCHelpMan getwalletinfo()
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
obj.pushKV("keypoolsize_hd_internal", pwallet->GetKeyPoolSize() - kpExternalSize);
if (pwallet->IsCrypted()) {
if (pwallet->HasEncryptionKeys()) {
obj.pushKV("unlocked_until", pwallet->nRelockTime);
}
obj.pushKV("paytxfee", ValueFromAmount(pwallet->m_pay_tx_fee.GetFeePerK()));
+4 -9
View File
@@ -765,7 +765,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
// Only descriptor wallets can be encrypted
Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
if (IsCrypted())
if (HasEncryptionKeys())
return false;
CKeyingMaterial plain_master_key;
@@ -3291,14 +3291,9 @@ bool CWallet::IsTxImmatureCoinBase(const CWalletTx& wtx) const
return GetTxBlocksToMaturity(wtx) > 0;
}
bool CWallet::IsCrypted() const
{
return HasEncryptionKeys();
}
bool CWallet::IsLocked() const
{
if (!IsCrypted()) {
if (!HasEncryptionKeys()) {
return false;
}
LOCK(cs_wallet);
@@ -3307,7 +3302,7 @@ bool CWallet::IsLocked() const
bool CWallet::Lock()
{
if (!IsCrypted())
if (!HasEncryptionKeys())
return false;
{
@@ -3521,7 +3516,7 @@ DescriptorScriptPubKeyMan& CWallet::SetupDescriptorScriptPubKeyMan(WalletBatch&
{
AssertLockHeld(cs_wallet);
auto spk_manager = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(*this, m_keypool_size));
if (IsCrypted()) {
if (HasEncryptionKeys()) {
if (IsLocked()) {
throw std::runtime_error(std::string(__func__) + ": Wallet is locked, cannot setup new descriptors");
}
-1
View File
@@ -489,7 +489,6 @@ public:
assert(NotifyUnload.empty());
}
bool IsCrypted() const;
bool IsLocked() const override;
bool Lock();
+1 -1
View File
@@ -98,7 +98,7 @@ static void WalletShowInfo(CWallet* wallet_instance)
tfm::format(std::cout, "Name: %s\n", wallet_instance->GetName());
tfm::format(std::cout, "Format: %s\n", wallet_instance->GetDatabase().Format());
tfm::format(std::cout, "Descriptors: %s\n", wallet_instance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) ? "yes" : "no");
tfm::format(std::cout, "Encrypted: %s\n", wallet_instance->IsCrypted() ? "yes" : "no");
tfm::format(std::cout, "Encrypted: %s\n", wallet_instance->HasEncryptionKeys() ? "yes" : "no");
tfm::format(std::cout, "HD (hd seed available): %s\n", wallet_instance->IsHDEnabled() ? "yes" : "no");
tfm::format(std::cout, "Keypool Size: %u\n", wallet_instance->GetKeyPoolSize());
tfm::format(std::cout, "Transactions: %zu\n", wallet_instance->mapWallet.size());