MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / PopulateWalletFromDB

Method PopulateWalletFromDB

src/wallet/wallet.cpp:2373–2425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2371}
2372
2373DBErrors CWallet::PopulateWalletFromDB(bilingual_str& error, std::vector<bilingual_str>& warnings)
2374{
2375 LOCK(cs_wallet);
2376
2377 Assert(m_spk_managers.empty());
2378 Assert(m_wallet_flags == 0);
2379 DBErrors nLoadWalletRet = WalletBatch(GetDatabase()).LoadWallet(this);
2380
2381 if (m_spk_managers.empty()) {
2382 assert(m_external_spk_managers.empty());
2383 assert(m_internal_spk_managers.empty());
2384 }
2385
2386 const auto wallet_file = m_database->Filename();
2387 switch (nLoadWalletRet) {
2388 case DBErrors::LOAD_OK:
2389 break;
2390 case DBErrors::NONCRITICAL_ERROR:
2391 warnings.push_back(strprintf(_("Error reading %s! All keys read correctly, but transaction data"
2392 " or address metadata may be missing or incorrect."),
2393 wallet_file));
2394 break;
2395 case DBErrors::NEED_RESCAN:
2396 warnings.push_back(strprintf(_("Error reading %s! Transaction data may be missing or incorrect."
2397 " Rescanning wallet."), wallet_file));
2398 break;
2399 case DBErrors::CORRUPT:
2400 error = strprintf(_("Error loading %s: Wallet corrupted"), wallet_file);
2401 break;
2402 case DBErrors::TOO_NEW:
2403 error = strprintf(_("Error loading %s: Wallet requires newer version of %s"), wallet_file, CLIENT_NAME);
2404 break;
2405 case DBErrors::EXTERNAL_SIGNER_SUPPORT_REQUIRED:
2406 error = strprintf(_("Error loading %s: External signer wallet being loaded without external signer support compiled"), wallet_file);
2407 break;
2408 case DBErrors::UNKNOWN_DESCRIPTOR:
2409 error = strprintf(_("Unrecognized descriptor found. Loading wallet %s\n\n"
2410 "The wallet might have been created on a newer version.\n"
2411 "Please try running the latest software version.\n"), wallet_file);
2412 break;
2413 case DBErrors::UNEXPECTED_LEGACY_ENTRY:
2414 error = strprintf(_("Unexpected legacy entry in descriptor wallet found. Loading wallet %s\n\n"
2415 "The wallet might have been tampered with or created with malicious intent.\n"), wallet_file);
2416 break;
2417 case DBErrors::LEGACY_WALLET:
2418 error = strprintf(_("Error loading %s: Wallet is a legacy wallet. Please migrate to a descriptor wallet using the migration tool (migratewallet RPC)."), wallet_file);
2419 break;
2420 case DBErrors::LOAD_FAIL:
2421 error = strprintf(_("Error loading %s"), wallet_file);
2422 break;
2423 } // no default case, so the compiler can warn about missing cases
2424 return nLoadWalletRet;
2425}
2426
2427util::Result<void> CWallet::RemoveTxs(std::vector<Txid>& txs_to_remove)
2428{

Callers 4

MakeWalletFunction · 0.80
LoadExistingMethod · 0.80
TestLoadWalletFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80

Calls 6

_Function · 0.85
LoadWalletMethod · 0.80
WalletBatchClass · 0.70
emptyMethod · 0.45
FilenameMethod · 0.45
push_backMethod · 0.45

Tested by 2

TestLoadWalletFunction · 0.64
BOOST_FIXTURE_TEST_CASEFunction · 0.64