wallet: Remove CWallet::nWalletVersion and related functions
This commit is contained in:
1 parent
7cda3d0f5b
commit
66de58208a
8 files changed
+2
-60
No files matched your search
@@ -47,7 +47,6 @@ public:
|
|||||||
virtual WalletDatabase& GetDatabase() const = 0;
|
virtual WalletDatabase& GetDatabase() const = 0;
|
||||||
virtual bool IsWalletFlagSet(uint64_t) const = 0;
|
virtual bool IsWalletFlagSet(uint64_t) const = 0;
|
||||||
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
|
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
|
||||||
virtual void SetMinVersion(enum WalletFeature, WalletBatch* = nullptr) = 0;
|
|
||||||
//! Pass the encryption key to cb().
|
//! Pass the encryption key to cb().
|
||||||
virtual bool WithEncryptionKey(std::function<bool (const CKeyingMaterial&)> cb) const = 0;
|
virtual bool WithEncryptionKey(std::function<bool (const CKeyingMaterial&)> cb) const = 0;
|
||||||
virtual bool HasEncryptionKeys() const = 0;
|
virtual bool HasEncryptionKeys() const = 0;
|
||||||
|
|||||||
@@ -492,7 +492,6 @@ BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, TestChain100Setup)
|
|||||||
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateMockableWalletDatabase());
|
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateMockableWalletDatabase());
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
|
||||||
wallet->SetMinVersion(FEATURE_LATEST);
|
|
||||||
wallet->SetWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
|
wallet->SetWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
|
||||||
BOOST_CHECK(!wallet->GetNewDestination(OutputType::BECH32, ""));
|
BOOST_CHECK(!wallet->GetNewDestination(OutputType::BECH32, ""));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -639,23 +639,6 @@ void CWallet::SetLastBlockProcessed(int block_height, uint256 block_hash)
|
|||||||
WriteBestBlock();
|
WriteBestBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallet::SetMinVersion(enum WalletFeature nVersion, WalletBatch* batch_in)
|
|
||||||
{
|
|
||||||
LOCK(cs_wallet);
|
|
||||||
if (nWalletVersion >= nVersion)
|
|
||||||
return;
|
|
||||||
WalletLogPrintf("Setting minversion to %d\n", nVersion);
|
|
||||||
nWalletVersion = nVersion;
|
|
||||||
|
|
||||||
{
|
|
||||||
WalletBatch* batch = batch_in ? batch_in : new WalletBatch(GetDatabase());
|
|
||||||
if (nWalletVersion > 40000)
|
|
||||||
batch->WriteMinVersion(nWalletVersion);
|
|
||||||
if (!batch_in)
|
|
||||||
delete batch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<Txid> CWallet::GetConflicts(const Txid& txid) const
|
std::set<Txid> CWallet::GetConflicts(const Txid& txid) const
|
||||||
{
|
{
|
||||||
std::set<Txid> result;
|
std::set<Txid> result;
|
||||||
@@ -821,9 +804,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encryption was introduced in version 0.4.0
|
|
||||||
SetMinVersion(FEATURE_WALLETCRYPT, encrypted_batch);
|
|
||||||
|
|
||||||
if (!encrypted_batch->TxnCommit()) {
|
if (!encrypted_batch->TxnCommit()) {
|
||||||
delete encrypted_batch;
|
delete encrypted_batch;
|
||||||
encrypted_batch = nullptr;
|
encrypted_batch = nullptr;
|
||||||
@@ -2871,9 +2851,6 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||||||
{
|
{
|
||||||
LOCK(walletInstance->cs_wallet);
|
LOCK(walletInstance->cs_wallet);
|
||||||
|
|
||||||
// ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key
|
|
||||||
walletInstance->SetMinVersion(FEATURE_LATEST);
|
|
||||||
|
|
||||||
// Init with passed flags.
|
// Init with passed flags.
|
||||||
// Always set the cache upgrade flag as this feature is supported from the beginning.
|
// Always set the cache upgrade flag as this feature is supported from the beginning.
|
||||||
walletInstance->InitWalletFlags(wallet_creation_flags | WALLET_FLAG_LAST_HARDENED_XPUB_CACHED);
|
walletInstance->InitWalletFlags(wallet_creation_flags | WALLET_FLAG_LAST_HARDENED_XPUB_CACHED);
|
||||||
|
|||||||
@@ -321,9 +321,6 @@ private:
|
|||||||
std::atomic<double> m_scanning_progress{0};
|
std::atomic<double> m_scanning_progress{0};
|
||||||
friend class WalletRescanReserver;
|
friend class WalletRescanReserver;
|
||||||
|
|
||||||
//! the current wallet version: clients below this version are not able to load the wallet
|
|
||||||
int nWalletVersion GUARDED_BY(cs_wallet){FEATURE_BASE};
|
|
||||||
|
|
||||||
/** The next scheduled rebroadcast of wallet transactions. */
|
/** The next scheduled rebroadcast of wallet transactions. */
|
||||||
NodeClock::time_point m_next_resend{GetDefaultNextResend()};
|
NodeClock::time_point m_next_resend{GetDefaultNextResend()};
|
||||||
/** Whether this wallet will submit newly created transactions to the node's mempool and
|
/** Whether this wallet will submit newly created transactions to the node's mempool and
|
||||||
@@ -585,8 +582,6 @@ public:
|
|||||||
//! Upgrade DescriptorCaches
|
//! Upgrade DescriptorCaches
|
||||||
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void UpgradeDescriptorCache() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
bool LoadMinVersion(int nVersion) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); nWalletVersion = nVersion; return true; }
|
|
||||||
|
|
||||||
//! Marks destination as previously spent.
|
//! Marks destination as previously spent.
|
||||||
void LoadAddressPreviouslySpent(const CTxDestination& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
void LoadAddressPreviouslySpent(const CTxDestination& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
//! Appends payment request to destination.
|
//! Appends payment request to destination.
|
||||||
@@ -822,9 +817,6 @@ public:
|
|||||||
|
|
||||||
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
//! signify that a particular wallet feature is now used.
|
|
||||||
void SetMinVersion(enum WalletFeature, WalletBatch* batch_in = nullptr) override;
|
|
||||||
|
|
||||||
//! Get wallet transactions that conflict with given transaction (spend same outputs)
|
//! Get wallet transactions that conflict with given transaction (spend same outputs)
|
||||||
std::set<Txid> GetConflicts(const Txid& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
std::set<Txid> GetConflicts(const Txid& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
|
|||||||
@@ -199,11 +199,6 @@ bool WalletBatch::WriteOrderPosNext(int64_t nOrderPosNext)
|
|||||||
return WriteIC(DBKeys::ORDERPOSNEXT, nOrderPosNext);
|
return WriteIC(DBKeys::ORDERPOSNEXT, nOrderPosNext);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletBatch::WriteMinVersion(int nVersion)
|
|
||||||
{
|
|
||||||
return WriteIC(DBKeys::MINVERSION, nVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WalletBatch::WriteActiveScriptPubKeyMan(uint8_t type, const uint256& id, bool internal)
|
bool WalletBatch::WriteActiveScriptPubKeyMan(uint8_t type, const uint256& id, bool internal)
|
||||||
{
|
{
|
||||||
std::string key = internal ? DBKeys::ACTIVEINTERNALSPK : DBKeys::ACTIVEEXTERNALSPK;
|
std::string key = internal ? DBKeys::ACTIVEINTERNALSPK : DBKeys::ACTIVEEXTERNALSPK;
|
||||||
@@ -442,19 +437,6 @@ bool LoadHDChain(CWallet* pwallet, DataStream& ssValue, std::string& strErr)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DBErrors LoadMinVersion(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
|
||||||
{
|
|
||||||
AssertLockHeld(pwallet->cs_wallet);
|
|
||||||
int nMinVersion = 0;
|
|
||||||
if (batch.Read(DBKeys::MINVERSION, nMinVersion)) {
|
|
||||||
pwallet->WalletLogPrintf("Wallet file version = %d\n", nMinVersion);
|
|
||||||
if (nMinVersion > FEATURE_LATEST)
|
|
||||||
return DBErrors::TOO_NEW;
|
|
||||||
pwallet->LoadMinVersion(nMinVersion);
|
|
||||||
}
|
|
||||||
return DBErrors::LOAD_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DBErrors LoadWalletFlags(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
static DBErrors LoadWalletFlags(CWallet* pwallet, DatabaseBatch& batch) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)
|
||||||
{
|
{
|
||||||
AssertLockHeld(pwallet->cs_wallet);
|
AssertLockHeld(pwallet->cs_wallet);
|
||||||
@@ -1137,8 +1119,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
|
|||||||
if (has_last_client) pwallet->WalletLogPrintf("Last client version = %d\n", last_client);
|
if (has_last_client) pwallet->WalletLogPrintf("Last client version = %d\n", last_client);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ((result = LoadMinVersion(pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;
|
|
||||||
|
|
||||||
// Load wallet flags, so they are known when processing other records.
|
// Load wallet flags, so they are known when processing other records.
|
||||||
// The FLAGS key is absent during wallet creation.
|
// The FLAGS key is absent during wallet creation.
|
||||||
if ((result = LoadWalletFlags(pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;
|
if ((result = LoadWalletFlags(pwallet, *m_batch)) != DBErrors::LOAD_OK) return result;
|
||||||
|
|||||||
@@ -241,8 +241,6 @@ public:
|
|||||||
|
|
||||||
bool WriteOrderPosNext(int64_t nOrderPosNext);
|
bool WriteOrderPosNext(int64_t nOrderPosNext);
|
||||||
|
|
||||||
bool WriteMinVersion(int nVersion);
|
|
||||||
|
|
||||||
bool WriteDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const CPrivKey& privkey);
|
bool WriteDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const CPrivKey& privkey);
|
||||||
bool WriteCryptedDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const std::vector<unsigned char>& secret);
|
bool WriteCryptedDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const std::vector<unsigned char>& secret);
|
||||||
bool WriteDescriptor(const uint256& desc_id, const WalletDescriptor& descriptor);
|
bool WriteDescriptor(const uint256& desc_id, const WalletDescriptor& descriptor);
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ static void WalletCreate(CWallet* wallet_instance, uint64_t wallet_creation_flag
|
|||||||
{
|
{
|
||||||
LOCK(wallet_instance->cs_wallet);
|
LOCK(wallet_instance->cs_wallet);
|
||||||
|
|
||||||
wallet_instance->SetMinVersion(FEATURE_LATEST);
|
|
||||||
wallet_instance->InitWalletFlags(wallet_creation_flags);
|
wallet_instance->InitWalletFlags(wallet_creation_flags);
|
||||||
|
|
||||||
Assert(wallet_instance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
|
Assert(wallet_instance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
|
||||||
|
|||||||
@@ -167,15 +167,13 @@ class CreateWalletTest(BitcoinTestFramework):
|
|||||||
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)
|
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)
|
||||||
|
|
||||||
self.log.info("Check that the version number is being logged correctly")
|
self.log.info("Check that the version number is being logged correctly")
|
||||||
with node.assert_debug_log(expected_msgs=[], unexpected_msgs=["Last client version = ", "Wallet file version = "]):
|
with node.assert_debug_log(expected_msgs=[], unexpected_msgs=["Last client version = "]):
|
||||||
node.createwallet("version_check")
|
node.createwallet("version_check")
|
||||||
wallet = node.get_wallet_rpc("version_check")
|
wallet = node.get_wallet_rpc("version_check")
|
||||||
wallet_version = wallet.getwalletinfo()["walletversion"]
|
|
||||||
client_version = node.getnetworkinfo()["version"]
|
client_version = node.getnetworkinfo()["version"]
|
||||||
wallet.unloadwallet()
|
wallet.unloadwallet()
|
||||||
with node.assert_debug_log(
|
with node.assert_debug_log(
|
||||||
expected_msgs=[f"Last client version = {client_version}", f"Wallet file version = {wallet_version}"],
|
expected_msgs=[f"Last client version = {client_version}"]
|
||||||
unexpected_msgs=["Wallet file version = 10500"]
|
|
||||||
):
|
):
|
||||||
node.loadwallet("version_check")
|
node.loadwallet("version_check")
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user