mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
scripted-diff: refactor: wallet: Delete IsCrypted
This function is a duplicate of HasEncryptionKeys().
-BEGIN VERIFY SCRIPT-
sed -i '/bool IsCrypted() const;/d' src/wallet/wallet.h
sed -i '/^bool CWallet::IsCrypted() const$/,/^}$/{/^}$/N;d;}' src/wallet/wallet.cpp
sed -i --regexp-extended 's/IsCrypted\(\)/HasEncryptionKeys()/g' $(git ls-files '*.cpp' '*.h')
-END VERIFY SCRIPT-
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -489,7 +489,6 @@ public:
|
||||
assert(NotifyUnload.empty());
|
||||
}
|
||||
|
||||
bool IsCrypted() const;
|
||||
bool IsLocked() const override;
|
||||
bool Lock();
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user