diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index edecd476ce5..c4abde8ba39 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -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; diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 535a4af5ecc..28c4d639323 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -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 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; diff --git a/src/wallet/rpc/encrypt.cpp b/src/wallet/rpc/encrypt.cpp index 0314090c8fc..e2c22ad6819 100644 --- a/src/wallet/rpc/encrypt.cpp +++ b/src/wallet/rpc/encrypt.cpp @@ -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 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 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."); } diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp index 8651b98d0bd..a2901dd4106 100644 --- a/src/wallet/rpc/wallet.cpp +++ b/src/wallet/rpc/wallet.cpp @@ -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())); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4becb340a9d..ed9bb8406d7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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(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"); } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 1d463564758..24d6b07d356 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -489,7 +489,6 @@ public: assert(NotifyUnload.empty()); } - bool IsCrypted() const; bool IsLocked() const override; bool Lock(); diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp index 6aaf08276b7..3e335bc36bd 100644 --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -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());