diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2020-10-19 08:24:27 -0400 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2020-10-21 08:48:43 -0400 |
commit | 01476a88a6095fd3af71cb9bf1eadef920a1197b (patch) | |
tree | 7a4770657da954423232d5ba82350ff696f81db4 /src/wallet/load.cpp | |
parent | b46f37ba5ec4fbd2e4c82343fc4f353d7f34837a (diff) | |
download | bitcoin-01476a88a6095fd3af71cb9bf1eadef920a1197b.tar.xz |
wallet: Make -wallet setting not create wallets
This changes -wallet setting to only load existing wallets, not create new ones.
- Fixes settings.json corner cases reported by sjors & promag:
https://github.com/bitcoin-core/gui/issues/95,
https://github.com/bitcoin/bitcoin/pull/19754#issuecomment-685858578,
https://github.com/bitcoin/bitcoin/pull/19754#issuecomment-685858578
- Prevents accidental creation of wallets reported most recently by jb55
http://www.erisian.com.au/bitcoin-core-dev/log-2020-09-14.html#l-355
- Simplifies behavior after #15454. #15454 took the big step of disabling
creation of the default wallet. This PR extends it to avoid creating other
wallets as well. With this change, new wallets just aren't created on
startup, instead of sometimes being created, sometimes not. #15454 release
notes are updated here and are simpler.
This change should be targeted for 0.21.0. It's a bug fix and simplifies
behavior of the #15937 / #19754 / #15454 features added in 0.21.0.
Diffstat (limited to 'src/wallet/load.cpp')
-rw-r--r-- | src/wallet/load.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp index 1b057000d2..1cdcb35fc7 100644 --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -71,11 +71,16 @@ bool VerifyWallets(interfaces::Chain& chain) DatabaseOptions options; DatabaseStatus status; + options.require_existing = true; options.verify = true; bilingual_str error_string; if (!MakeWalletDatabase(wallet_file, options, status, error_string)) { - chain.initError(error_string); - return false; + if (status == DatabaseStatus::FAILED_NOT_FOUND) { + chain.initWarning(Untranslated(strprintf("Skipping -wallet path that doesn't exist. %s\n", error_string.original))); + } else { + chain.initError(error_string); + return false; + } } } @@ -88,10 +93,14 @@ bool LoadWallets(interfaces::Chain& chain) for (const std::string& name : gArgs.GetArgs("-wallet")) { DatabaseOptions options; DatabaseStatus status; + options.require_existing = true; options.verify = false; // No need to verify, assuming verified earlier in VerifyWallets() bilingual_str error; std::vector<bilingual_str> warnings; std::unique_ptr<WalletDatabase> database = MakeWalletDatabase(name, options, status, error); + if (!database && status == DatabaseStatus::FAILED_NOT_FOUND) { + continue; + } std::shared_ptr<CWallet> pwallet = database ? CWallet::Create(chain, name, std::move(database), options.create_flags, error, warnings) : nullptr; if (!warnings.empty()) chain.initWarning(Join(warnings, Untranslated("\n"))); if (!pwallet) { |