mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +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
|
enum EncryptionStatus
|
||||||
{
|
{
|
||||||
NoKeys, // wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)
|
NoKeys, // wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)
|
||||||
Unencrypted, // !wallet->IsCrypted()
|
Unencrypted, // !wallet->HasEncryptionKeys()
|
||||||
Locked, // wallet->IsCrypted() && wallet->IsLocked()
|
Locked, // wallet->HasEncryptionKeys() && wallet->IsLocked()
|
||||||
Unlocked // wallet->IsCrypted() && !wallet->IsLocked()
|
Unlocked // wallet->HasEncryptionKeys() && !wallet->IsLocked()
|
||||||
};
|
};
|
||||||
|
|
||||||
OptionsModel* getOptionsModel() const;
|
OptionsModel* getOptionsModel() const;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public:
|
|||||||
{
|
{
|
||||||
return m_wallet->EncryptWallet(wallet_passphrase);
|
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 lock() override { return m_wallet->Lock(); }
|
||||||
bool unlock(const SecureString& wallet_passphrase) override { return m_wallet->Unlock(wallet_passphrase); }
|
bool unlock(const SecureString& wallet_passphrase) override { return m_wallet->Unlock(wallet_passphrase); }
|
||||||
bool isLocked() override { return m_wallet->IsLocked(); }
|
bool isLocked() override { return m_wallet->IsLocked(); }
|
||||||
@@ -623,7 +623,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto wallets{GetWallets(m_context)};
|
auto wallets{GetWallets(m_context)};
|
||||||
auto it = std::find_if(wallets.begin(), wallets.end(), [&](std::shared_ptr<CWallet> w){ return w->GetName() == wallet_name; });
|
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
|
// Unloaded wallet, read db
|
||||||
DatabaseOptions options;
|
DatabaseOptions options;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ RPCHelpMan walletpassphrase()
|
|||||||
{
|
{
|
||||||
LOCK(pwallet->cs_wallet);
|
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.");
|
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);
|
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
|
||||||
if (!pwallet) return UniValue::VNULL;
|
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.");
|
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);
|
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
|
||||||
if (!pwallet) return UniValue::VNULL;
|
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.");
|
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.");
|
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.");
|
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", (int64_t)kpExternalSize);
|
||||||
obj.pushKV("keypoolsize_hd_internal", pwallet->GetKeyPoolSize() - kpExternalSize);
|
obj.pushKV("keypoolsize_hd_internal", pwallet->GetKeyPoolSize() - kpExternalSize);
|
||||||
|
|
||||||
if (pwallet->IsCrypted()) {
|
if (pwallet->HasEncryptionKeys()) {
|
||||||
obj.pushKV("unlocked_until", pwallet->nRelockTime);
|
obj.pushKV("unlocked_until", pwallet->nRelockTime);
|
||||||
}
|
}
|
||||||
obj.pushKV("paytxfee", ValueFromAmount(pwallet->m_pay_tx_fee.GetFeePerK()));
|
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
|
// Only descriptor wallets can be encrypted
|
||||||
Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
|
Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
|
||||||
|
|
||||||
if (IsCrypted())
|
if (HasEncryptionKeys())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CKeyingMaterial plain_master_key;
|
CKeyingMaterial plain_master_key;
|
||||||
@@ -3291,14 +3291,9 @@ bool CWallet::IsTxImmatureCoinBase(const CWalletTx& wtx) const
|
|||||||
return GetTxBlocksToMaturity(wtx) > 0;
|
return GetTxBlocksToMaturity(wtx) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::IsCrypted() const
|
|
||||||
{
|
|
||||||
return HasEncryptionKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CWallet::IsLocked() const
|
bool CWallet::IsLocked() const
|
||||||
{
|
{
|
||||||
if (!IsCrypted()) {
|
if (!HasEncryptionKeys()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
@@ -3307,7 +3302,7 @@ bool CWallet::IsLocked() const
|
|||||||
|
|
||||||
bool CWallet::Lock()
|
bool CWallet::Lock()
|
||||||
{
|
{
|
||||||
if (!IsCrypted())
|
if (!HasEncryptionKeys())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -3521,7 +3516,7 @@ DescriptorScriptPubKeyMan& CWallet::SetupDescriptorScriptPubKeyMan(WalletBatch&
|
|||||||
{
|
{
|
||||||
AssertLockHeld(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
auto spk_manager = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(*this, m_keypool_size));
|
auto spk_manager = std::unique_ptr<DescriptorScriptPubKeyMan>(new DescriptorScriptPubKeyMan(*this, m_keypool_size));
|
||||||
if (IsCrypted()) {
|
if (HasEncryptionKeys()) {
|
||||||
if (IsLocked()) {
|
if (IsLocked()) {
|
||||||
throw std::runtime_error(std::string(__func__) + ": Wallet is locked, cannot setup new descriptors");
|
throw std::runtime_error(std::string(__func__) + ": Wallet is locked, cannot setup new descriptors");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -489,7 +489,6 @@ public:
|
|||||||
assert(NotifyUnload.empty());
|
assert(NotifyUnload.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsCrypted() const;
|
|
||||||
bool IsLocked() const override;
|
bool IsLocked() const override;
|
||||||
bool Lock();
|
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, "Name: %s\n", wallet_instance->GetName());
|
||||||
tfm::format(std::cout, "Format: %s\n", wallet_instance->GetDatabase().Format());
|
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, "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, "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, "Keypool Size: %u\n", wallet_instance->GetKeyPoolSize());
|
||||||
tfm::format(std::cout, "Transactions: %zu\n", wallet_instance->mapWallet.size());
|
tfm::format(std::cout, "Transactions: %zu\n", wallet_instance->mapWallet.size());
|
||||||
|
|||||||
Reference in New Issue
Block a user