Skip to content

Commit 66de582

Browse files
committed
wallet: Remove CWallet::nWalletVersion and related functions
1 parent 7cda3d0 commit 66de582

File tree

8 files changed

+2
-60
lines changed

8 files changed

+2
-60
lines changed

src/wallet/scriptpubkeyman.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class WalletStorage
4747
virtual WalletDatabase& GetDatabase() const = 0;
4848
virtual bool IsWalletFlagSet(uint64_t) const = 0;
4949
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
50-
virtual void SetMinVersion(enum WalletFeature, WalletBatch* = nullptr) = 0;
5150
//! Pass the encryption key to cb().
5251
virtual bool WithEncryptionKey(std::function<bool (const CKeyingMaterial&)> cb) const = 0;
5352
virtual bool HasEncryptionKeys() const = 0;

src/wallet/test/wallet_tests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, TestChain100Setup)
492492
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateMockableWalletDatabase());
493493
LOCK(wallet->cs_wallet);
494494
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
495-
wallet->SetMinVersion(FEATURE_LATEST);
496495
wallet->SetWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
497496
BOOST_CHECK(!wallet->GetNewDestination(OutputType::BECH32, ""));
498497
}

src/wallet/wallet.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -639,23 +639,6 @@ void CWallet::SetLastBlockProcessed(int block_height, uint256 block_hash)
639639
WriteBestBlock();
640640
}
641641

642-
void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in)
643-
{
644-
LOCK(cs_wallet);
645-
if (nWalletVersion >= nVersion)
646-
return;
647-
WalletLogPrintf("Setting minversion to %d\n", nVersion);
648-
nWalletVersion = nVersion;
649-
650-
{
651-
WalletBatch* batch = batch_in ? batch_in : new WalletBatch(GetDatabase());
652-
if (nWalletVersion > 40000)
653-
batch->WriteMinVersion(nWalletVersion);
654-
if (!batch_in)
655-
delete batch;
656-
}
657-
}
658-
659642
std::set<Txid> CWallet::GetConflicts(const Txid& txid) const
660643
{
661644
std::set<Txid> result;
@@ -821,9 +804,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
821804
}
822805
}
823806

824-
// Encryption was introduced in version 0.4.0
825-
SetMinVersion(FEATURE_WALLETCRYPT, encrypted_batch);
826-
827807
if (!encrypted_batch->TxnCommit()) {
828808
delete encrypted_batch;
829809
encrypted_batch = nullptr;
@@ -2871,9 +2851,6 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
28712851
{
28722852
LOCK(walletInstance->cs_wallet);
28732853

2874-
// ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key
2875-
walletInstance->SetMinVersion(FEATURE_LATEST);
2876-
28772854
// Init with passed flags.
28782855
// Always set the cache upgrade flag as this feature is supported from the beginning.
28792856
walletInstance->InitWalletFlags(wallet_creation_flags | WALLET_FLAG_LAST_HARDENED_XPUB_CACHED);

src/wallet/wallet.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
321321
std::atomic<double> m_scanning_progress{0};
322322
friend class WalletRescanReserver;
323323

324-
//! the current wallet version: clients below this version are not able to load the wallet
325-
int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
326-
327324
/** The next scheduled rebroadcast of wallet transactions. */
328325
NodeClock::time_point m_next_resend{GetDefaultNextResend()};
329326
/** Whether this wallet will submit newly created transactions to the node's mempool and
@@ -585,8 +582,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
585582
//! Upgrade DescriptorCaches
586583
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
587584

588-
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; return true; }
589-
590585
//! Marks destination as previously spent.
591586
void LoadAddressPreviouslySpent(const CTxDestination& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
592587
//! Appends payment request to destination.
@@ -822,9 +817,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
822817

823818
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
824819

825-
//! signify that a particular wallet feature is now used.
826-
void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr) override;
827-
828820
//! Get wallet transactions that conflict with given transaction (spend same outputs)
829821
std::set<Txid> GetConflicts(const Txid& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
830822

src/wallet/walletdb.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ bool WalletBatch::WriteOrderPosNext(int64_t nOrderPosNext)
199199
return WriteIC(DBKeys::ORDERPOSNEXT, nOrderPosNext);
200200
}
201201

202-
bool WalletBatch::WriteMinVersion(int nVersion)
203-
{
204-
return WriteIC(DBKeys::MINVERSION, nVersion);
205-
}
206-
207202
bool WalletBatch::WriteActiveScriptPubKeyMan(uint8_t type, const uint256& id, bool internal)
208203
{
209204
std::string key = internal ? DBKeys::ACTIVEINTERNALSPK : DBKeys::ACTIVEEXTERNALSPK;
@@ -442,19 +437,6 @@ bool LoadHDChain(CWallet* pwallet, DataStream& ssValue, std::string& strErr)
442437
return true;
443438
}
444439

445-
static DBErrors LoadMinVersion(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
446-
{
447-
AssertLockHeld(pwallet->cs_wallet);
448-
int nMinVersion = 0;
449-
if (batch.Read(DBKeys::MINVERSION, nMinVersion)) {
450-
pwallet->WalletLogPrintf("Wallet file version = %d\n", nMinVersion);
451-
if (nMinVersion > FEATURE_LATEST)
452-
return DBErrors::TOO_NEW;
453-
pwallet->LoadMinVersion(nMinVersion);
454-
}
455-
return DBErrors::LOAD_OK;
456-
}
457-
458440
static DBErrors LoadWalletFlags(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
459441
{
460442
AssertLockHeld(pwallet->cs_wallet);
@@ -1137,8 +1119,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
11371119
if (has_last_client) pwallet->WalletLogPrintf("Last client version = %d\n", last_client);
11381120

11391121
try {
1140-
if ((result = LoadMinVersion(pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;
1141-
11421122
// Load wallet flags, so they are known when processing other records.
11431123
// The FLAGS key is absent during wallet creation.
11441124
if ((result = LoadWalletFlags(pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;

src/wallet/walletdb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ class WalletBatch
241241

242242
bool WriteOrderPosNext(int64_t nOrderPosNext);
243243

244-
bool WriteMinVersion(int nVersion);
245-
246244
bool WriteDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const CPrivKey& privkey);
247245
bool WriteCryptedDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const std::vector<unsigned char>& secret);
248246
bool WriteDescriptor(const uint256& desc_id, const WalletDescriptor& descriptor);

src/wallet/wallettool.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ static void WalletCreate(CWallet* wallet_instance, uint64_t wallet_creation_flag
3131
{
3232
LOCK(wallet_instance->cs_wallet);
3333

34-
wallet_instance->SetMinVersion(FEATURE_LATEST);
3534
wallet_instance->InitWalletFlags(wallet_creation_flags);
3635

3736
Assert(wallet_instance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));

test/functional/wallet_createwallet.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,13 @@ def run_test(self):
167167
assert_raises_rpc_error(-4, 'descriptors argument must be set to "true"; it is no longer possible to create a legacy wallet.', self.nodes[0].createwallet, wallet_name="legacy", descriptors=False)
168168

169169
self.log.info("Check that the version number is being logged correctly")
170-
with node.assert_debug_log(expected_msgs=[], unexpected_msgs=["Last client version = ", "Wallet file version = "]):
170+
with node.assert_debug_log(expected_msgs=[], unexpected_msgs=["Last client version = "]):
171171
node.createwallet("version_check")
172172
wallet = node.get_wallet_rpc("version_check")
173-
wallet_version = wallet.getwalletinfo()["walletversion"]
174173
client_version = node.getnetworkinfo()["version"]
175174
wallet.unloadwallet()
176175
with node.assert_debug_log(
177-
expected_msgs=[f"Last client version = {client_version}", f"Wallet file version = {wallet_version}"],
178-
unexpected_msgs=["Wallet file version = 10500"]
176+
expected_msgs=[f"Last client version = {client_version}"]
179177
):
180178
node.loadwallet("version_check")
181179

0 commit comments

Comments
 (0)