Skip to content

Commit d4c409c

Browse files
committed
Merge bitcoin/bitcoin#20773: refactor: split CWallet::Create
489ebb7 wallet: make chain optional for CWallet::Create (Ivan Metlushko) d73ae93 CWallet::Create move chain init message up into calling code (Ivan Metlushko) 44c430f refactor: Add CWallet:::AttachChain method (Russell Yanofsky) e2a47ce refactor: move first run detection to client code (Ivan Metlushko) Pull request description: This is a followup for bitcoin/bitcoin#20365 (comment) First part of a refactoring with overall goal to simplify `CWallet` and de-duplicate code with `wallettool` **Rationale**: split `CWallet::Create` and create `CWallet::AttachChain`. `CWallet::AttachChain` takes chain as first parameter on purpose. In future I suggest we can remove `chain` from `CWallet` constructor. The second commit is based on be164f9cf89b123f03b926aa980996919924ee64 from #15719 (thanks ryanofsky) cc ryanofsky achow101 ACKs for top commit: ryanofsky: Code review ACK 489ebb7. Only changes since last review were adding a const variable declaration, and implementing suggestion not to move feerate option checks to AttachChain. Thanks for updates and fast responses! Tree-SHA512: 00235abfe1b00874c56c449adcab8a36582424abb9ba27440bf750af8f3f217b68c11ca74eb30f78a2109ad1d9009315480effc78345e16a3074a1b5d8128721
2 parents 39d597d + 489ebb7 commit d4c409c

File tree

11 files changed

+93
-68
lines changed

11 files changed

+93
-68
lines changed

src/bench/wallet_balance.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
2222
CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockWalletDatabase()};
2323
{
2424
wallet.SetupLegacyScriptPubKeyMan();
25-
bool first_run;
26-
if (wallet.LoadWallet(first_run) != DBErrors::LOAD_OK) assert(false);
25+
if (wallet.LoadWallet() != DBErrors::LOAD_OK) assert(false);
2726
}
2827
auto handler = test_setup->m_node.chain->handleNotifications({&wallet, [](CWallet*) {}});
2928

src/qt/test/addressbooktests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
6363
node.setContext(&test.m_node);
6464
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
6565
wallet->SetupLegacyScriptPubKeyMan();
66-
bool firstRun;
67-
wallet->LoadWallet(firstRun);
66+
wallet->LoadWallet();
6867

6968
auto build_address = [&wallet]() {
7069
CKey key;

src/qt/test/wallettests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ void TestGUI(interfaces::Node& node)
140140
}
141141
node.setContext(&test.m_node);
142142
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
143-
bool firstRun;
144-
wallet->LoadWallet(firstRun);
143+
wallet->LoadWallet();
145144
{
146145
auto spk_man = wallet->GetOrCreateLegacyScriptPubKeyMan();
147146
LOCK2(wallet->cs_wallet, spk_man->cs_KeyStore);

src/wallet/dump.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ bool CreateFromDump(const std::string& name, const fs::path& wallet_path, biling
194194
std::shared_ptr<CWallet> wallet(new CWallet(nullptr /* chain */, name, std::move(database)), WalletToolReleaseWallet);
195195
{
196196
LOCK(wallet->cs_wallet);
197-
bool first_run = true;
198-
DBErrors load_wallet_ret = wallet->LoadWallet(first_run);
197+
DBErrors load_wallet_ret = wallet->LoadWallet();
199198
if (load_wallet_ret != DBErrors::LOAD_OK) {
200199
error = strprintf(_("Error creating %s"), name);
201200
return false;

src/wallet/load.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ bool LoadWallets(interfaces::Chain& chain)
105105
if (!database && status == DatabaseStatus::FAILED_NOT_FOUND) {
106106
continue;
107107
}
108-
std::shared_ptr<CWallet> pwallet = database ? CWallet::Create(chain, name, std::move(database), options.create_flags, error, warnings) : nullptr;
108+
chain.initMessage(_("Loading wallet...").translated);
109+
std::shared_ptr<CWallet> pwallet = database ? CWallet::Create(&chain, name, std::move(database), options.create_flags, error, warnings) : nullptr;
109110
if (!warnings.empty()) chain.initWarning(Join(warnings, Untranslated("\n")));
110111
if (!pwallet) {
111112
chain.initError(error);

src/wallet/test/coinselector_tests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
297297
empty_wallet();
298298
{
299299
std::unique_ptr<CWallet> wallet = std::make_unique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
300-
bool firstRun;
301-
wallet->LoadWallet(firstRun);
300+
wallet->LoadWallet();
302301
wallet->SetupLegacyScriptPubKeyMan();
303302
LOCK(wallet->cs_wallet);
304303
add_coin(*wallet, 5 * CENT, 6 * 24, false, 0, true);

src/wallet/test/wallet_test_fixture.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
88
: TestingSetup(chainName),
99
m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
1010
{
11-
bool fFirstRun;
12-
m_wallet.LoadWallet(fFirstRun);
11+
m_wallet.LoadWallet();
1312
m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
1413
m_wallet_client->registerRpcs();
1514
}

src/wallet/test/wallet_tests.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ static_assert(WALLET_INCREMENTAL_RELAY_FEE >= DEFAULT_INCREMENTAL_RELAY_FEE, "wa
3838

3939
BOOST_FIXTURE_TEST_SUITE(wallet_tests, WalletTestingSetup)
4040

41-
static std::shared_ptr<CWallet> TestLoadWallet(interfaces::Chain& chain)
41+
static std::shared_ptr<CWallet> TestLoadWallet(interfaces::Chain* chain)
4242
{
4343
DatabaseOptions options;
4444
DatabaseStatus status;
4545
bilingual_str error;
4646
std::vector<bilingual_str> warnings;
4747
auto database = MakeWalletDatabase("", options, status, error);
4848
auto wallet = CWallet::Create(chain, "", std::move(database), options.create_flags, error, warnings);
49-
wallet->postInitProcess();
49+
if (chain) {
50+
wallet->postInitProcess();
51+
}
5052
return wallet;
5153
}
5254

@@ -483,8 +485,7 @@ class ListCoinsTestingSetup : public TestChain100Setup
483485
LOCK2(wallet->cs_wallet, ::cs_main);
484486
wallet->SetLastBlockProcessed(::ChainActive().Height(), ::ChainActive().Tip()->GetBlockHash());
485487
}
486-
bool firstRun;
487-
wallet->LoadWallet(firstRun);
488+
wallet->LoadWallet();
488489
AddKey(*wallet, coinbaseKey);
489490
WalletRescanReserver reserver(*wallet);
490491
reserver.reserve();
@@ -690,7 +691,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
690691
{
691692
gArgs.ForceSetArg("-unsafesqlitesync", "1");
692693
// Create new wallet with known key and unload it.
693-
auto wallet = TestLoadWallet(*m_node.chain);
694+
auto wallet = TestLoadWallet(m_node.chain.get());
694695
CKey key;
695696
key.MakeNewKey(true);
696697
AddKey(*wallet, key);
@@ -730,7 +731,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
730731

731732
// Reload wallet and make sure new transactions are detected despite events
732733
// being blocked
733-
wallet = TestLoadWallet(*m_node.chain);
734+
wallet = TestLoadWallet(m_node.chain.get());
734735
BOOST_CHECK(rescan_completed);
735736
BOOST_CHECK_EQUAL(addtx_count, 2);
736737
{
@@ -770,7 +771,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
770771
ENTER_CRITICAL_SECTION(wallet->wallet()->cs_wallet);
771772
ENTER_CRITICAL_SECTION(cs_wallets);
772773
});
773-
wallet = TestLoadWallet(*m_node.chain);
774+
wallet = TestLoadWallet(m_node.chain.get());
774775
BOOST_CHECK_EQUAL(addtx_count, 4);
775776
{
776777
LOCK(wallet->cs_wallet);
@@ -782,10 +783,17 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
782783
TestUnloadWallet(std::move(wallet));
783784
}
784785

786+
BOOST_FIXTURE_TEST_CASE(CreateWalletWithoutChain, BasicTestingSetup)
787+
{
788+
auto wallet = TestLoadWallet(nullptr);
789+
BOOST_CHECK(wallet);
790+
UnloadWallet(std::move(wallet));
791+
}
792+
785793
BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
786794
{
787795
gArgs.ForceSetArg("-unsafesqlitesync", "1");
788-
auto wallet = TestLoadWallet(*m_node.chain);
796+
auto wallet = TestLoadWallet(m_node.chain.get());
789797
CKey key;
790798
key.MakeNewKey(true);
791799
AddKey(*wallet, key);

src/wallet/wallet.cpp

Lines changed: 59 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ std::shared_ptr<CWallet> LoadWalletInternal(interfaces::Chain& chain, const std:
213213
return nullptr;
214214
}
215215

216-
std::shared_ptr<CWallet> wallet = CWallet::Create(chain, name, std::move(database), options.create_flags, error, warnings);
216+
chain.initMessage(_("Loading wallet...").translated);
217+
std::shared_ptr<CWallet> wallet = CWallet::Create(&chain, name, std::move(database), options.create_flags, error, warnings);
217218
if (!wallet) {
218219
error = Untranslated("Wallet loading failed.") + Untranslated(" ") + error;
219220
status = DatabaseStatus::FAILED_LOAD;
@@ -292,7 +293,8 @@ std::shared_ptr<CWallet> CreateWallet(interfaces::Chain& chain, const std::strin
292293
}
293294

294295
// Make the wallet
295-
std::shared_ptr<CWallet> wallet = CWallet::Create(chain, name, std::move(database), wallet_creation_flags, error, warnings);
296+
chain.initMessage(_("Loading wallet...").translated);
297+
std::shared_ptr<CWallet> wallet = CWallet::Create(&chain, name, std::move(database), wallet_creation_flags, error, warnings);
296298
if (!wallet) {
297299
error = Untranslated("Wallet creation failed.") + Untranslated(" ") + error;
298300
status = DatabaseStatus::FAILED_CREATE;
@@ -3247,11 +3249,10 @@ void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
32473249
}
32483250
}
32493251

3250-
DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
3252+
DBErrors CWallet::LoadWallet()
32513253
{
32523254
LOCK(cs_wallet);
32533255

3254-
fFirstRunRet = false;
32553256
DBErrors nLoadWalletRet = WalletBatch(GetDatabase()).LoadWallet(this);
32563257
if (nLoadWalletRet == DBErrors::NEED_REWRITE)
32573258
{
@@ -3263,9 +3264,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
32633264
}
32643265
}
32653266

3266-
// This wallet is in its first run if there are no ScriptPubKeyMans and it isn't blank or no privkeys
3267-
fFirstRunRet = m_spk_managers.empty() && !IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) && !IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET);
3268-
if (fFirstRunRet) {
3267+
if (m_spk_managers.empty()) {
32693268
assert(m_external_spk_managers.empty());
32703269
assert(m_internal_spk_managers.empty());
32713270
}
@@ -3886,18 +3885,15 @@ std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, cons
38863885
return MakeDatabase(wallet_path, options, status, error_string);
38873886
}
38883887

3889-
std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings)
3888+
std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings)
38903889
{
38913890
const std::string& walletFile = database->Filename();
38923891

3893-
chain.initMessage(_("Loading wallet…").translated);
3894-
38953892
int64_t nStart = GetTimeMillis();
3896-
bool fFirstRun = true;
38973893
// TODO: Can't use std::make_shared because we need a custom deleter but
38983894
// should be possible to use std::allocate_shared.
3899-
std::shared_ptr<CWallet> walletInstance(new CWallet(&chain, name, std::move(database)), ReleaseWallet);
3900-
DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun);
3895+
std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
3896+
DBErrors nLoadWalletRet = walletInstance->LoadWallet();
39013897
if (nLoadWalletRet != DBErrors::LOAD_OK) {
39023898
if (nLoadWalletRet == DBErrors::CORRUPT) {
39033899
error = strprintf(_("Error loading %s: Wallet corrupted"), walletFile);
@@ -3924,6 +3920,10 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
39243920
}
39253921
}
39263922

3923+
// This wallet is in its first run if there are no ScriptPubKeyMans and it isn't blank or no privkeys
3924+
const bool fFirstRun = walletInstance->m_spk_managers.empty() &&
3925+
!walletInstance->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS) &&
3926+
!walletInstance->IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET);
39273927
if (fFirstRun)
39283928
{
39293929
// ensure this wallet.dat can only be opened by clients supporting HD with chain split and expects no default key
@@ -3952,7 +3952,9 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
39523952
}
39533953
}
39543954

3955-
walletInstance->chainStateFlushed(chain.getTipLocator());
3955+
if (chain) {
3956+
walletInstance->chainStateFlushed(chain->getTipLocator());
3957+
}
39563958
} else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) {
39573959
// Make it impossible to disable private keys after creation
39583960
error = strprintf(_("Error loading %s: Private keys can only be disabled during creation"), walletFile);
@@ -4049,9 +4051,9 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
40494051
_("This is the transaction fee you will pay if you send a transaction."));
40504052
}
40514053
walletInstance->m_pay_tx_fee = CFeeRate(nFeePerK, 1000);
4052-
if (walletInstance->m_pay_tx_fee < chain.relayMinFee()) {
4054+
if (chain && walletInstance->m_pay_tx_fee < chain->relayMinFee()) {
40534055
error = strprintf(_("Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"),
4054-
gArgs.GetArg("-paytxfee", ""), chain.relayMinFee().ToString());
4056+
gArgs.GetArg("-paytxfee", ""), chain->relayMinFee().ToString());
40554057
return nullptr;
40564058
}
40574059
}
@@ -4065,15 +4067,15 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
40654067
if (nMaxFee > HIGH_MAX_TX_FEE) {
40664068
warnings.push_back(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
40674069
}
4068-
if (CFeeRate(nMaxFee, 1000) < chain.relayMinFee()) {
4070+
if (chain && CFeeRate(nMaxFee, 1000) < chain->relayMinFee()) {
40694071
error = strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
4070-
gArgs.GetArg("-maxtxfee", ""), chain.relayMinFee().ToString());
4072+
gArgs.GetArg("-maxtxfee", ""), chain->relayMinFee().ToString());
40714073
return nullptr;
40724074
}
40734075
walletInstance->m_default_max_tx_fee = nMaxFee;
40744076
}
40754077

4076-
if (chain.relayMinFee().GetFeePerK() > HIGH_TX_FEE_PER_KB) {
4078+
if (chain && chain->relayMinFee().GetFeePerK() > HIGH_TX_FEE_PER_KB) {
40774079
warnings.push_back(AmountHighWarn("-minrelaytxfee") + Untranslated(" ") +
40784080
_("The wallet will avoid paying less than the minimum relay fee."));
40794081
}
@@ -4089,6 +4091,35 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
40894091

40904092
LOCK(walletInstance->cs_wallet);
40914093

4094+
if (chain && !AttachChain(walletInstance, *chain, error, warnings)) {
4095+
return nullptr;
4096+
}
4097+
4098+
{
4099+
LOCK(cs_wallets);
4100+
for (auto& load_wallet : g_load_wallet_fns) {
4101+
load_wallet(interfaces::MakeWallet(walletInstance));
4102+
}
4103+
}
4104+
4105+
walletInstance->SetBroadcastTransactions(gArgs.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
4106+
4107+
{
4108+
walletInstance->WalletLogPrintf("setKeyPool.size() = %u\n", walletInstance->GetKeyPoolSize());
4109+
walletInstance->WalletLogPrintf("mapWallet.size() = %u\n", walletInstance->mapWallet.size());
4110+
walletInstance->WalletLogPrintf("m_address_book.size() = %u\n", walletInstance->m_address_book.size());
4111+
}
4112+
4113+
return walletInstance;
4114+
}
4115+
4116+
bool CWallet::AttachChain(const std::shared_ptr<CWallet>& walletInstance, interfaces::Chain& chain, bilingual_str& error, std::vector<bilingual_str>& warnings)
4117+
{
4118+
LOCK(walletInstance->cs_wallet);
4119+
// allow setting the chain if it hasn't been set already but prevent changing it
4120+
assert(!walletInstance->m_chain || walletInstance->m_chain == &chain);
4121+
walletInstance->m_chain = &chain;
4122+
40924123
// Register wallet with validationinterface. It's done before rescan to avoid
40934124
// missing block connections between end of rescan and validation subscribing.
40944125
// Because of wallet lock being hold, block connection notifications are going to
@@ -4122,21 +4153,21 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
41224153

41234154
if (tip_height && *tip_height != rescan_height)
41244155
{
4125-
// We can't rescan beyond non-pruned blocks, stop and throw an error.
4126-
// This might happen if a user uses an old wallet within a pruned node
4127-
// or if they ran -disablewallet for a longer time, then decided to re-enable
41284156
if (chain.havePruned()) {
4129-
// Exit early and print an error.
4130-
// If a block is pruned after this check, we will load the wallet,
4131-
// but fail the rescan with a generic error.
41324157
int block_height = *tip_height;
41334158
while (block_height > 0 && chain.haveBlockOnDisk(block_height - 1) && rescan_height != block_height) {
41344159
--block_height;
41354160
}
41364161

41374162
if (rescan_height != block_height) {
4163+
// We can't rescan beyond non-pruned blocks, stop and throw an error.
4164+
// This might happen if a user uses an old wallet within a pruned node
4165+
// or if they ran -disablewallet for a longer time, then decided to re-enable
4166+
// Exit early and print an error.
4167+
// If a block is pruned after this check, we will load the wallet,
4168+
// but fail the rescan with a generic error.
41384169
error = _("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)");
4139-
return nullptr;
4170+
return false;
41404171
}
41414172
}
41424173

@@ -4158,29 +4189,14 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
41584189
WalletRescanReserver reserver(*walletInstance);
41594190
if (!reserver.reserve() || (ScanResult::SUCCESS != walletInstance->ScanForWalletTransactions(chain.getBlockHash(rescan_height), rescan_height, {} /* max height */, reserver, true /* update */).status)) {
41604191
error = _("Failed to rescan the wallet during initialization");
4161-
return nullptr;
4192+
return false;
41624193
}
41634194
}
41644195
walletInstance->chainStateFlushed(chain.getTipLocator());
41654196
walletInstance->GetDatabase().IncrementUpdateCounter();
41664197
}
41674198

4168-
{
4169-
LOCK(cs_wallets);
4170-
for (auto& load_wallet : g_load_wallet_fns) {
4171-
load_wallet(interfaces::MakeWallet(walletInstance));
4172-
}
4173-
}
4174-
4175-
walletInstance->SetBroadcastTransactions(gArgs.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
4176-
4177-
{
4178-
walletInstance->WalletLogPrintf("setKeyPool.size() = %u\n", walletInstance->GetKeyPoolSize());
4179-
walletInstance->WalletLogPrintf("mapWallet.size() = %u\n", walletInstance->mapWallet.size());
4180-
walletInstance->WalletLogPrintf("m_address_book.size() = %u\n", walletInstance->m_address_book.size());
4181-
}
4182-
4183-
return walletInstance;
4199+
return true;
41844200
}
41854201

41864202
const CAddressBookData* CWallet::FindAddressBookEntry(const CTxDestination& dest, bool allow_change) const

src/wallet/wallet.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,13 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
763763

764764
bool CreateTransactionInternal(const std::vector<CRecipient>& vecSend, CTransactionRef& tx, CAmount& nFeeRet, int& nChangePosInOut, bilingual_str& error, const CCoinControl& coin_control, FeeCalculation& fee_calc_out, bool sign);
765765

766+
/**
767+
* Catch wallet up to current chain, scanning new blocks, updating the best
768+
* block locator and m_last_block_processed, and registering for
769+
* notifications about new blocks and transactions.
770+
*/
771+
static bool AttachChain(const std::shared_ptr<CWallet>& wallet, interfaces::Chain& chain, bilingual_str& error, std::vector<bilingual_str>& warnings);
772+
766773
public:
767774
/**
768775
* Main wallet lock.
@@ -1126,7 +1133,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
11261133
CAmount GetChange(const CTransaction& tx) const;
11271134
void chainStateFlushed(const CBlockLocator& loc) override;
11281135

1129-
DBErrors LoadWallet(bool& fFirstRunRet);
1136+
DBErrors LoadWallet();
11301137
DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
11311138

11321139
bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);
@@ -1202,7 +1209,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
12021209
bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
12031210

12041211
/* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
1205-
static std::shared_ptr<CWallet> Create(interfaces::Chain& chain, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings);
1212+
static std::shared_ptr<CWallet> Create(interfaces::Chain* chain, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings);
12061213

12071214
/**
12081215
* Wallet post-init setup

0 commit comments

Comments
 (0)