Right now, if a GUI user leaves a wallet loaded and something happens to make it error at startup, they’re stuck.
This turns the error dialog into a question about starting without the wallet instead.
Right now, if a GUI user leaves a wallet loaded and something happens to make it error at startup, they’re stuck.
This turns the error dialog into a question about starting without the wallet instead.
Not sure why GitHub thinks this has conflicts - it doesn’t.
Mainly this is a WIP because it uses a hacky global to avoid trying to load the wallets the user has chosen to skip… Suggestions for a good way to deal with that?
Still gives me error message without ability to continue, not question.
0$ ./src/qt/bitcoin-qt -version
1Bitcoin Core versija v22.99.0-fb3ea0ad3a87
2Copyright (C) 2009-2021 The Bitcoin Core developers
3
4Please contribute if you find Bitcoin Core useful. Visit
5<https://bitcoincore.org/> for further information about the software.
6The source code is available from <https://github.com/bitcoin/bitcoin>.
7
8This is experimental software.
9Distributed under the MIT software license, see the accompanying file COPYING
10or <https://opensource.org/licenses/MIT>
11
12$ git log | head -n 1
13commit fb3ea0ad3a8788e023b9ba7237c26fc8ef0dba79
14$ ./src/qt/bitcoin-qt -signet
15Error: Error loading /fast_home/neonz/.bitcoin/signet/wallets/jmw/wallet.dat: Wallet requires newer version of Bitcoin Core
22@@ -22,6 +23,17 @@
23 #include <system_error>
24
25 namespace wallet {
26+
27+bool HandleWalletLoadError(interfaces::Chain& chain, const std::string& wallet_file, const bilingual_str& error_string)
28+{
29+ if (!chain.initQuestion(error_string + Untranslated("\n\n") + _("Continue without wallet?"), error_string, _("Error"), CClientUIInterface::MSG_ERROR | CClientUIInterface::MODAL | CClientUIInterface::BTN_OK | CClientUIInterface::BTN_ABORT)) {
115 }
116 }
117
118+ if (modified_wallet_list) {
119+ // Ensure new wallet list overrides commandline options
120+ args.ForceSetArgV("wallet", chain.getRwSetting("wallet"));
In commit “Bugfix: GUI: Allow the user to start anyway when loading a wallet errors” (cc85951352a4ebf8464f415b2a2ec66b7773fbd5)
Two issues this line:
bitcoin.conf
or command line wallets from being loaded if modified_wallet_list
is true, because getRwSetting()
doesn’t return these wallets (it only returns settings.json
wallets).ForceSet
call is changing wallet process args, but code that runs later in LoadWallet
is calling chain.getSettingsList
which reads the node process args instead of wallet process args. The code was confused even before this PR, but this change would make it actually not work correctly.Would suggest a change like the following as a fix:
0diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
1index 6f900a64375..5c7c66a62ba 100644
2--- a/src/interfaces/chain.h
3+++ b/src/interfaces/chain.h
4@@ -270,6 +270,10 @@ public:
5 //! Get list of settings values.
6 virtual std::vector<util::SettingsValue> getSettingsList(const std::string& arg) = 0;
7
8+ //! Override setting in memory, so future getSetting / GetArg calls return
9+ //! specified value. If value is null, will unset any previously forced value.
10+ virtual void forceSetting(const std::string& name, const util::SettingsValue& value) = 0;
11+
12 //! Return <datadir>/settings.json setting value.
13 virtual util::SettingsValue getRwSetting(const std::string& name) = 0;
14
15diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
16index 364a8406af7..0f2f90c11e5 100644
17--- a/src/node/interfaces.cpp
18+++ b/src/node/interfaces.cpp
19@@ -692,6 +692,16 @@ public:
20 {
21 return gArgs.GetSettingsList(name);
22 }
23+ void forceSetting(const std::string& name, const util::SettingsValue& value) override
24+ {
25+ gArgs.LockSettings([&](util::Settings& settings) {
26+ if (value.isNull()) {
27+ settings.forced_settings.erase(name);
28+ } else {
29+ settings.forced_settings[name] = value;
30+ }
31+ });
32+ }
33 util::SettingsValue getRwSetting(const std::string& name) override
34 {
35 util::SettingsValue result;
36diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp
37index ecd832d6224..8a1164ae71d 100644
38--- a/src/wallet/load.cpp
39+++ b/src/wallet/load.cpp
40@@ -66,7 +66,7 @@ bool VerifyWallets(WalletContext& context)
41
42 // For backwards compatibility if an unnamed top level wallet exists in the
43 // wallets directory, include it in the default list of wallets to load.
44- if (!args.IsArgSet("wallet")) {
45+ if (chain.getSetting("wallet").isNull()) {
46 DatabaseOptions options;
47 DatabaseStatus status;
48 bilingual_str error_string;
49@@ -86,6 +86,7 @@ bool VerifyWallets(WalletContext& context)
50 std::set<fs::path> wallet_paths;
51
52 bool modified_wallet_list = false;
53+ util::SettingsValue verified_wallets{UniValue::VARR};
54 for (const auto& wallet : chain.getSettingsList("wallet")) {
55 const auto& wallet_file = wallet.get_str();
56 const fs::path path = fsbridge::AbsPathJoin(GetWalletDir(), fs::PathFromString(wallet_file));
57@@ -110,12 +111,14 @@ bool VerifyWallets(WalletContext& context)
58 return false;
59 }
60 }
61+ } else {
62+ verified_wallets.push_back(wallet_file);
63 }
64 }
65
66 if (modified_wallet_list) {
67- // Ensure new wallet list overrides commandline options
68- args.ForceSetArgV("wallet", chain.getRwSetting("wallet"));
69+ // Prevent loading any command-line or bitcoin.conf wallets that failed to verify.
70+ chain.forceSetting("wallet", verified_wallets);
71 }
72
73 return true;
bitcoin.conf
or command line wallets will be loaded even if they were present and could be verified. I suggested a fix for this below.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
@luke-jr do you want to respond to suggestions here? Or would you be open to a someone making a new PR?
Status of the PR seems to be that it is up to date, but has a bug that could cause command line and bitcoin.conf wallets to be ignored. I suggested a fix for the bug and some cleanups in #236 (review).
I think there is also a usability problem with this PR in the case of temporary errors where a wallet can’t be loaded due to a temporary issue like: background assumeutxo download https://github.com/bitcoin/bitcoin/pull/23997, pruning, a missing external signer https://github.com/bitcoin/bitcoin/pull/22173, an encrypted drive not being mounted, a removable drive not being plugged in, or a version incompatibility that will be resolved by upgrading or downgrading. In these cases it would be useful to have the option to continue starting the GUI and letting the node sync, while temporarily not loading individual wallets that are unavailable, and the current dialog doesn’t provide an option to temporarily not load a wallet. The only options are quit or continue without loading the wallet next time. I think it would be a improvement to change the dialog to “Wallet could not be loaded because of , do you want to try to load it next time Bitcoin Core is started?” with “Yes” “No” buttons (and maybe “Details” and “Abort” buttons off to the side like #379). This was one of four alternatives suggested in #95, and there is more discussion about this issue there.