Bugfix: Allow the user to start anyway when loading a wallet errors #236

pull luke-jr wants to merge 3 commits into bitcoin-core:master from luke-jr:gui_init_walleterror_cont changing 5 files +42 −6
  1. luke-jr commented at 1:08 am on March 3, 2021: member

    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.

  2. luke-jr commented at 1:09 am on March 3, 2021: member

    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?

  3. hebasto added the label UX on May 9, 2021
  4. hebasto added the label Wallet on May 9, 2021
  5. Sjors cross-referenced this on May 12, 2021 from issue wallet: bitcoind fails to auto-load a non-empty external-signer wallet by hebasto
  6. luke-jr force-pushed on Jul 30, 2021
  7. DrahtBot added the label Needs rebase on Dec 13, 2021
  8. luke-jr force-pushed on Jan 10, 2022
  9. luke-jr marked this as ready for review on Jan 10, 2022
  10. luke-jr commented at 1:52 am on January 10, 2022: member
    Rebased, which made it practical to drop the global hack. This seems ready for review now.
  11. DrahtBot removed the label Needs rebase on Jan 10, 2022
  12. luke-jr cross-referenced this on Mar 5, 2022 from issue wallet: Add external-signer-support specific error message by hebasto
  13. kristapsk commented at 6:14 pm on March 6, 2022: contributor
    Concept ACK, will review / test.
  14. kristapsk commented at 4:18 pm on March 8, 2022: contributor

    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
    

    image

  15. luke-jr commented at 10:53 pm on March 8, 2022: member
    Ah, it only caught some errors. Pushed a revision that should catch the rest.
  16. luke-jr force-pushed on Mar 8, 2022
  17. util: Add a ForceSetArgV that can handle non-strings bc89fbe723
  18. interfaces/chain: Provide a way to ask the user a question during init 6c12879048
  19. luke-jr force-pushed on Mar 8, 2022
  20. in src/wallet/load.cpp:29 in 243dc118e1 outdated
    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)) {
    


    kristapsk commented at 2:35 am on March 9, 2022:
    Maybe better question message would be “Continue without this wallet?”, so that is clear that only wallet having error is not being loaded, not all other wallets or wallet functionality disabled altogether?

    luke-jr commented at 3:35 am on March 9, 2022:
    Sounds good, done
  21. kristapsk commented at 2:36 am on March 9, 2022: contributor
    Apart from review comment above, ACK, working for me (tested scenario with trying to load external signer wallet without external signer support compiled into Bitcoin Core).
  22. luke-jr force-pushed on Mar 9, 2022
  23. kristapsk approved
  24. kristapsk commented at 8:21 am on March 9, 2022: contributor
    ACK cc85951352a4ebf8464f415b2a2ec66b7773fbd5
  25. hebasto requested review from ryanofsky on Apr 4, 2022
  26. in src/wallet/load.cpp:118 in cc85951352 outdated
    115         }
    116     }
    117 
    118+    if (modified_wallet_list) {
    119+        // Ensure new wallet list overrides commandline options
    120+        args.ForceSetArgV("wallet", chain.getRwSetting("wallet"));
    


    ryanofsky commented at 7:22 pm on April 4, 2022:

    In commit “Bugfix: GUI: Allow the user to start anyway when loading a wallet errors” (cc85951352a4ebf8464f415b2a2ec66b7773fbd5)

    Two issues this line:

    1. This prevents all 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).
    2. This line has no effect if wallet code is running in a separate process, because 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;
    
  27. ryanofsky commented at 8:09 pm on April 4, 2022: contributor
    Nice fix! I think there is a minor problem in the implementation, where if a user chooses not to load any wallet, none of the 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.
  28. hebasto renamed this:
    Bugfix: GUI: Allow the user to start anyway when loading a wallet errors
    Bugfix: Allow the user to start anyway when loading a wallet errors
    on Apr 15, 2022
  29. hebasto added the label Waiting for author on Jun 1, 2022
  30. DrahtBot commented at 9:49 pm on June 12, 2022: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    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.

  31. Bugfix: GUI: Allow the user to start anyway when loading a wallet errors 6cbea59a35
  32. luke-jr force-pushed on Sep 5, 2022
  33. ryanofsky commented at 4:47 pm on October 6, 2022: contributor

    @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.

  34. DrahtBot cross-referenced this on Oct 23, 2022 from issue refactor: Use util::Result class for wallet loading by ryanofsky
  35. DrahtBot cross-referenced this on Oct 24, 2022 from issue util: Fix -norpcwhitelist, -norpcallowip, and similar corner case behavior by ryanofsky
  36. DrahtBot cross-referenced this on Oct 24, 2022 from issue refactor: Remove settings merge reverse precedence code by ryanofsky
  37. DrahtBot cross-referenced this on Oct 24, 2022 from issue refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags by ryanofsky
  38. DrahtBot cross-referenced this on Oct 24, 2022 from issue util: Forbid ambiguous multiple assignments in config file by ryanofsky
  39. DrahtBot cross-referenced this on Oct 24, 2022 from issue refactor: Implement missing error checking for ArgsManager flags by ryanofsky
  40. hebasto removed the label Waiting for author on Dec 6, 2022
  41. hebasto commented at 7:09 pm on December 6, 2022: member

    @luke-jr do you want to respond to suggestions here? Or would you be open to a someone making a new PR?

    I’m going to close this, and mark “Up for grabs”.

  42. hebasto closed this on Dec 6, 2022

  43. hebasto added the label Up for grabs on Dec 6, 2022
  44. bitcoin-core locked this on Dec 6, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-23 00:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me