Skip to content

Commit c575990

Browse files
committed
Merge bitcoin/bitcoin#34147: scripted-diff: refactor: wallet: Delete duplicate IsCrypted()
11ce5cf 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 11ce5cf 🔀 billymcbip: utACK [11ce5cf](bitcoin/bitcoin@11ce5cf) polespinasa: code review tACK 11ce5cf rkrux: crACK 11ce5cf Tree-SHA512: 24bd9fedb17fab092346953558b25a2e4181d8f3750cedd0ecf3939291216190d442a38c93aa6829a3a88e60d94b90cada42136c24fd0fabe367994fc1e89690
2 parents eb0594e + 11ce5cf commit c575990

File tree

7 files changed

+15
-21
lines changed

7 files changed

+15
-21
lines changed

src/qt/walletmodel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class WalletModel : public QObject
6868
enum EncryptionStatus
6969
{
7070
NoKeys, // wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)
71-
Unencrypted, // !wallet->IsCrypted()
72-
Locked, // wallet->IsCrypted() && wallet->IsLocked()
73-
Unlocked // wallet->IsCrypted() && !wallet->IsLocked()
71+
Unencrypted, // !wallet->HasEncryptionKeys()
72+
Locked, // wallet->HasEncryptionKeys() && wallet->IsLocked()
73+
Unlocked // wallet->HasEncryptionKeys() && !wallet->IsLocked()
7474
};
7575

7676
OptionsModel* getOptionsModel() const;

src/wallet/interfaces.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class WalletImpl : public Wallet
140140
{
141141
return m_wallet->EncryptWallet(wallet_passphrase);
142142
}
143-
bool isCrypted() override { return m_wallet->IsCrypted(); }
143+
bool isCrypted() override { return m_wallet->HasEncryptionKeys(); }
144144
bool lock() override { return m_wallet->Lock(); }
145145
bool unlock(const SecureString& wallet_passphrase) override { return m_wallet->Unlock(wallet_passphrase); }
146146
bool isLocked() override { return m_wallet->IsLocked(); }
@@ -623,7 +623,7 @@ class WalletLoaderImpl : public WalletLoader
623623
{
624624
auto wallets{GetWallets(m_context)};
625625
auto it = std::find_if(wallets.begin(), wallets.end(), [&](std::shared_ptr<CWallet> w){ return w->GetName() == wallet_name; });
626-
if (it != wallets.end()) return (*it)->IsCrypted();
626+
if (it != wallets.end()) return (*it)->HasEncryptionKeys();
627627

628628
// Unloaded wallet, read db
629629
DatabaseOptions options;

src/wallet/rpc/encrypt.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ RPCHelpMan walletpassphrase()
4545
{
4646
LOCK(pwallet->cs_wallet);
4747

48-
if (!pwallet->IsCrypted()) {
48+
if (!pwallet->HasEncryptionKeys()) {
4949
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrase was called.");
5050
}
5151

@@ -134,7 +134,7 @@ RPCHelpMan walletpassphrasechange()
134134
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
135135
if (!pwallet) return UniValue::VNULL;
136136

137-
if (!pwallet->IsCrypted()) {
137+
if (!pwallet->HasEncryptionKeys()) {
138138
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called.");
139139
}
140140

@@ -199,7 +199,7 @@ RPCHelpMan walletlock()
199199
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
200200
if (!pwallet) return UniValue::VNULL;
201201

202-
if (!pwallet->IsCrypted()) {
202+
if (!pwallet->HasEncryptionKeys()) {
203203
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called.");
204204
}
205205

@@ -256,7 +256,7 @@ RPCHelpMan encryptwallet()
256256
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: wallet does not contain private keys, nothing to encrypt.");
257257
}
258258

259-
if (pwallet->IsCrypted()) {
259+
if (pwallet->HasEncryptionKeys()) {
260260
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called.");
261261
}
262262

src/wallet/rpc/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static RPCHelpMan getwalletinfo()
9393
obj.pushKV("keypoolsize", (int64_t)kpExternalSize);
9494
obj.pushKV("keypoolsize_hd_internal", pwallet->GetKeyPoolSize() - kpExternalSize);
9595

96-
if (pwallet->IsCrypted()) {
96+
if (pwallet->HasEncryptionKeys()) {
9797
obj.pushKV("unlocked_until", pwallet->nRelockTime);
9898
}
9999
obj.pushKV("paytxfee", ValueFromAmount(pwallet->m_pay_tx_fee.GetFeePerK()));

src/wallet/wallet.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
765765
// Only descriptor wallets can be encrypted
766766
Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
767767

768-
if (IsCrypted())
768+
if (HasEncryptionKeys())
769769
return false;
770770

771771
CKeyingMaterial plain_master_key;
@@ -3291,14 +3291,9 @@ bool CWallet::IsTxImmatureCoinBase(const CWalletTx& wtx) const
32913291
return GetTxBlocksToMaturity(wtx) > 0;
32923292
}
32933293

3294-
bool CWallet::IsCrypted() const
3295-
{
3296-
return HasEncryptionKeys();
3297-
}
3298-
32993294
bool CWallet::IsLocked() const
33003295
{
3301-
if (!IsCrypted()) {
3296+
if (!HasEncryptionKeys()) {
33023297
return false;
33033298
}
33043299
LOCK(cs_wallet);
@@ -3307,7 +3302,7 @@ bool CWallet::IsLocked() const
33073302

33083303
bool CWallet::Lock()
33093304
{
3310-
if (!IsCrypted())
3305+
if (!HasEncryptionKeys())
33113306
return false;
33123307

33133308
{
@@ -3521,7 +3516,7 @@ DescriptorScriptPubKeyMan& CWallet::SetupDescriptorScriptPubKeyMan(WalletBatch&
35213516
{
35223517
AssertLockHeld(cs_wallet);
35233518
auto spk_manager = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(*this, m_keypool_size));
3524-
if (IsCrypted()) {
3519+
if (HasEncryptionKeys()) {
35253520
if (IsLocked()) {
35263521
throw std::runtime_error(std::string(__func__) + ": Wallet is locked, cannot setup new descriptors");
35273522
}

src/wallet/wallet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
489489
assert(NotifyUnload.empty());
490490
}
491491

492-
bool IsCrypted() const;
493492
bool IsLocked() const override;
494493
bool Lock();
495494

src/wallet/wallettool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void WalletShowInfo(CWallet* wallet_instance)
9898
tfm::format(std::cout, "Name: %s\n", wallet_instance->GetName());
9999
tfm::format(std::cout, "Format: %s\n", wallet_instance->GetDatabase().Format());
100100
tfm::format(std::cout, "Descriptors: %s\n", wallet_instance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) ? "yes" : "no");
101-
tfm::format(std::cout, "Encrypted: %s\n", wallet_instance->IsCrypted() ? "yes" : "no");
101+
tfm::format(std::cout, "Encrypted: %s\n", wallet_instance->HasEncryptionKeys() ? "yes" : "no");
102102
tfm::format(std::cout, "HD (hd seed available): %s\n", wallet_instance->IsHDEnabled() ? "yes" : "no");
103103
tfm::format(std::cout, "Keypool Size: %u\n", wallet_instance->GetKeyPoolSize());
104104
tfm::format(std::cout, "Transactions: %zu\n", wallet_instance->mapWallet.size());

0 commit comments

Comments
 (0)