Skip to content

Commit 03d95cc

Browse files
committed
Merge bitcoin#29375: wallet: remove unused 'accept_no_keys' arg from decryption process
2bb25ce wallet: remove unused 'accept_no_keys' arg from decryption process (furszy) Pull request description: Found it while reviewing other PR. Couldn't contain myself from cleaning it up. The wallet decryption process (`CheckDecryptionKey()` and `Unlock()`) contains an arg 'accept_no_keys,' introduced in bitcoin#13926, that has never been used. Additionally, this also removes the unimplemented `SplitWalletPath` function. ACKs for top commit: delta1: ACK 2bb25ce epiccurious: utACK 2bb25ce. achow101: ACK 2bb25ce theStack: Code-review ACK 2bb25ce Tree-SHA512: e0537c994be19ca0032551d8a64cf1755c8997e04d21ee0522b31de26ad90b9eb02a8b415448257b60bced484b9d2a23b37586e12dc5ff6e35bdd8ff2165c6bf
2 parents 4de8455 + 2bb25ce commit 03d95cc

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

Diff for: src/wallet/db.h

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class ArgsManager;
2020
struct bilingual_str;
2121

2222
namespace wallet {
23-
void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename);
2423

2524
class DatabaseCursor
2625
{

Diff for: src/wallet/scriptpubkeyman.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ isminetype LegacyScriptPubKeyMan::IsMine(const CScript& script) const
225225
assert(false);
226226
}
227227

228-
bool LegacyScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys)
228+
bool LegacyScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master_key)
229229
{
230230
{
231231
LOCK(cs_KeyStore);
@@ -258,7 +258,7 @@ bool LegacyScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master_key
258258
LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n");
259259
throw std::runtime_error("Error unlocking wallet: some keys decrypt but not all. Your wallet file may be corrupt.");
260260
}
261-
if (keyFail || (!keyPass && !accept_no_keys))
261+
if (keyFail || !keyPass)
262262
return false;
263263
fDecryptionThoroughlyChecked = true;
264264
}
@@ -2049,7 +2049,7 @@ isminetype DescriptorScriptPubKeyMan::IsMine(const CScript& script) const
20492049
return ISMINE_NO;
20502050
}
20512051

2052-
bool DescriptorScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys)
2052+
bool DescriptorScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master_key)
20532053
{
20542054
LOCK(cs_desc_man);
20552055
if (!m_map_keys.empty()) {
@@ -2074,7 +2074,7 @@ bool DescriptorScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master
20742074
LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n");
20752075
throw std::runtime_error("Error unlocking wallet: some keys decrypt but not all. Your wallet file may be corrupt.");
20762076
}
2077-
if (keyFail || (!keyPass && !accept_no_keys)) {
2077+
if (keyFail || !keyPass) {
20782078
return false;
20792079
}
20802080
m_decryption_thoroughly_checked = true;

Diff for: src/wallet/scriptpubkeyman.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class ScriptPubKeyMan
179179
virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; }
180180

181181
//! Check that the given decryption key is valid for this ScriptPubKeyMan, i.e. it decrypts all of the keys handled by it.
182-
virtual bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) { return false; }
182+
virtual bool CheckDecryptionKey(const CKeyingMaterial& master_key) { return false; }
183183
virtual bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) { return false; }
184184

185185
virtual util::Result<CTxDestination> GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) { return util::Error{Untranslated("Not supported")}; }
@@ -379,7 +379,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv
379379
util::Result<CTxDestination> GetNewDestination(const OutputType type) override;
380380
isminetype IsMine(const CScript& script) const override;
381381

382-
bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) override;
382+
bool CheckDecryptionKey(const CKeyingMaterial& master_key) override;
383383
bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) override;
384384

385385
util::Result<CTxDestination> GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) override;
@@ -610,7 +610,7 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan
610610
util::Result<CTxDestination> GetNewDestination(const OutputType type) override;
611611
isminetype IsMine(const CScript& script) const override;
612612

613-
bool CheckDecryptionKey(const CKeyingMaterial& master_key, bool accept_no_keys = false) override;
613+
bool CheckDecryptionKey(const CKeyingMaterial& master_key) override;
614614
bool Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) override;
615615

616616
util::Result<CTxDestination> GetReservedDestination(const OutputType type, bool internal, int64_t& index, CKeyPool& keypool) override;

Diff for: src/wallet/wallet.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void CWallet::UpgradeDescriptorCache()
555555
SetWalletFlag(WALLET_FLAG_LAST_HARDENED_XPUB_CACHED);
556556
}
557557

558-
bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys)
558+
bool CWallet::Unlock(const SecureString& strWalletPassphrase)
559559
{
560560
CCrypter crypter;
561561
CKeyingMaterial _vMasterKey;
@@ -568,7 +568,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool accept_no_key
568568
return false;
569569
if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, _vMasterKey))
570570
continue; // try another master key
571-
if (Unlock(_vMasterKey, accept_no_keys)) {
571+
if (Unlock(_vMasterKey)) {
572572
// Now that we've unlocked, upgrade the key metadata
573573
UpgradeKeyMetadata();
574574
// Now that we've unlocked, upgrade the descriptor cache
@@ -3374,12 +3374,12 @@ bool CWallet::Lock()
33743374
return true;
33753375
}
33763376

3377-
bool CWallet::Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no_keys)
3377+
bool CWallet::Unlock(const CKeyingMaterial& vMasterKeyIn)
33783378
{
33793379
{
33803380
LOCK(cs_wallet);
33813381
for (const auto& spk_man_pair : m_spk_managers) {
3382-
if (!spk_man_pair.second->CheckDecryptionKey(vMasterKeyIn, accept_no_keys)) {
3382+
if (!spk_man_pair.second->CheckDecryptionKey(vMasterKeyIn)) {
33833383
return false;
33843384
}
33853385
}

Diff for: src/wallet/wallet.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
302302
private:
303303
CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet);
304304

305-
bool Unlock(const CKeyingMaterial& vMasterKeyIn, bool accept_no_keys = false);
305+
bool Unlock(const CKeyingMaterial& vMasterKeyIn);
306306

307307
std::atomic<bool> fAbortRescan{false};
308308
std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
@@ -578,7 +578,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
578578
// Used to prevent deleting the passphrase from memory when it is still in use.
579579
RecursiveMutex m_relock_mutex;
580580

581-
bool Unlock(const SecureString& strWalletPassphrase, bool accept_no_keys = false);
581+
bool Unlock(const SecureString& strWalletPassphrase);
582582
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
583583
bool EncryptWallet(const SecureString& strWalletPassphrase);
584584

0 commit comments

Comments
 (0)