Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864904
D17642.id52550.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
D17642.id52550.diff
View Options
diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp
--- a/src/bench/wallet_balance.cpp
+++ b/src/bench/wallet_balance.cpp
@@ -30,8 +30,7 @@
CreateMockWalletDatabase()};
{
wallet.SetupLegacyScriptPubKeyMan();
- bool first_run;
- if (wallet.LoadWallet(first_run) != DBErrors::LOAD_OK) {
+ if (wallet.LoadWallet() != DBErrors::LOAD_OK) {
assert(false);
}
}
diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp
--- a/src/qt/test/addressbooktests.cpp
+++ b/src/qt/test/addressbooktests.cpp
@@ -67,9 +67,7 @@
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(
node.context()->chain.get(), "", CreateMockWalletDatabase());
wallet->SetupLegacyScriptPubKeyMan();
-
- bool firstRun;
- wallet->LoadWallet(firstRun);
+ wallet->LoadWallet();
auto build_address = [&wallet]() {
CKey key;
diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp
--- a/src/qt/test/wallettests.cpp
+++ b/src/qt/test/wallettests.cpp
@@ -120,9 +120,7 @@
node.setContext(&test.m_node);
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(
node.context()->chain.get(), "", CreateMockWalletDatabase());
-
- bool firstRun;
- wallet->LoadWallet(firstRun);
+ wallet->LoadWallet();
ChainstateManager &chainman = *Assert(node.context()->chainman);
{
auto spk_man = wallet->GetOrCreateLegacyScriptPubKeyMan();
diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp
--- a/src/wallet/test/coinselector_tests.cpp
+++ b/src/wallet/test/coinselector_tests.cpp
@@ -330,8 +330,7 @@
{
auto wallet = std::make_unique<CWallet>(m_node.chain.get(), "",
CreateMockWalletDatabase());
- bool firstRun;
- wallet->LoadWallet(firstRun);
+ wallet->LoadWallet();
LOCK(wallet->cs_wallet);
wallet->SetupLegacyScriptPubKeyMan();
add_coin(*wallet, 5 * CENT, 6 * 24, false, 0, true);
diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp
--- a/src/wallet/test/wallet_test_fixture.cpp
+++ b/src/wallet/test/wallet_test_fixture.cpp
@@ -13,8 +13,7 @@
: TestingSetup(chainName), m_wallet_client{interfaces::MakeWalletClient(
*m_node.chain, *Assert(m_node.args))},
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase()) {
- bool fFirstRun;
- m_wallet.LoadWallet(fFirstRun);
+ m_wallet.LoadWallet();
m_chain_notifications_handler =
m_node.chain->handleNotifications({&m_wallet, [](CWallet *) {}});
m_wallet_client->registerRpcs();
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -566,8 +566,7 @@
wallet->SetLastBlockProcessed(chainman.ActiveHeight(),
chainman.ActiveTip()->GetBlockHash());
}
- bool firstRun;
- wallet->LoadWallet(firstRun);
+ wallet->LoadWallet();
AddKey(*wallet, coinbaseKey);
WalletRescanReserver reserver(*wallet);
reserver.reserve();
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -789,7 +789,7 @@
Amount GetDebit(const CTransaction &tx, const isminefilter &filter) const;
void chainStateFlushed(const CBlockLocator &loc) override;
- DBErrors LoadWallet(bool &fFirstRunRet);
+ DBErrors LoadWallet();
DBErrors ZapSelectTx(std::vector<TxId> &txIdsIn,
std::vector<TxId> &txIdsOut)
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2168,10 +2168,9 @@
}
}
-DBErrors CWallet::LoadWallet(bool &fFirstRunRet) {
+DBErrors CWallet::LoadWallet() {
LOCK(cs_wallet);
- fFirstRunRet = false;
DBErrors nLoadWalletRet = WalletBatch(*database).LoadWallet(this);
if (nLoadWalletRet == DBErrors::NEED_REWRITE) {
if (database->Rewrite("\x04pool")) {
@@ -2181,12 +2180,7 @@
}
}
- // This wallet is in its first run if there are no ScriptPubKeyMans and it
- // isn't blank or no privkeys
- fFirstRunRet = m_spk_managers.empty() &&
- !IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) &&
- !IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET);
- if (fFirstRunRet) {
+ if (m_spk_managers.empty()) {
assert(m_external_spk_managers.empty());
assert(m_internal_spk_managers.empty());
}
@@ -2713,12 +2707,11 @@
chain.initMessage(_("Loading wallet...").translated);
int64_t nStart = GetTimeMillis();
- bool fFirstRun = true;
// TODO: Can't use std::make_shared because we need a custom deleter but
// should be possible to use std::allocate_shared.
std::shared_ptr<CWallet> walletInstance(
new CWallet(&chain, name, std::move(database)), ReleaseWallet);
- DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun);
+ DBErrors nLoadWalletRet = walletInstance->LoadWallet();
if (nLoadWalletRet != DBErrors::LOAD_OK) {
if (nLoadWalletRet == DBErrors::CORRUPT) {
error =
@@ -2748,6 +2741,12 @@
}
}
+ // This wallet is in its first run if there are no ScriptPubKeyMans and it
+ // isn't blank or no privkeys
+ const bool fFirstRun =
+ walletInstance->m_spk_managers.empty() &&
+ !walletInstance->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) &&
+ !walletInstance->IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET);
if (fFirstRun) {
// Ensure this wallet.dat can only be opened by clients supporting
// HD with chain split and expects no default key.
diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp
--- a/src/wallet/wallettool.cpp
+++ b/src/wallet/wallettool.cpp
@@ -60,8 +60,7 @@
WalletToolReleaseWallet};
DBErrors load_wallet_ret;
try {
- bool first_run;
- load_wallet_ret = wallet_instance->LoadWallet(first_run);
+ load_wallet_ret = wallet_instance->LoadWallet();
} catch (const std::runtime_error &) {
tfm::format(
std::cerr,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 20, 23:05 (4 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866128
Default Alt Text
D17642.id52550.diff (6 KB)
Attached To
D17642: refactor: move first run detection to client code
Event Timeline
Log In to Comment