Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate bitcoind and bitcoin-qt init code #27150

Merged
merged 4 commits into from
Mar 7, 2023

Commits on Feb 28, 2023

  1. scripted-diff: Remove double newlines after some init errors

    Some InitError calls had trailing \n characters, causing double newlines in
    error output. After this change InitError calls consistently output one newline
    instead of two. Appearance of messages in the GUI does not seem to be affected.
    Can be tested with:
    
      src/bitcoind -regtest -datadir=noexist
      src/qt/bitcoin-qt -regtest -datadir=noexist
    
    -BEGIN VERIFY SCRIPT-
    git grep -l InitError src/ | xargs sed -i 's/\(InitError(.*\)\\n"/\1"/'
    -END VERIFY SCRIPT-
    ryanofsky committed Feb 28, 2023
    Configuration menu
    Copy the full SHA
    c361df9 View commit details
    Browse the repository at this point in the history
  2. Extend bilingual_str support for tinyformat

    Previous bilingual_str tinyformat::format accepted bilingual format strings,
    but not bilingual arguments. Extend it to accept both. This is useful when
    embedding one translated string inside another translated string, for example:
    `strprintf(_("Error: %s"), message)` which would fail previously if `message`
    was a bilingual_str.
    ryanofsky committed Feb 28, 2023
    Configuration menu
    Copy the full SHA
    3db2874 View commit details
    Browse the repository at this point in the history
  3. Add InitError(error, details) overload

    This is only used in the current PR to avoid ugly
    `strprintf(Untranslated("%s:\n%s"), str, MakeUnorderedList(details)`
    boilerplate in init code. But in the future the function could be extended and
    more widely used to include more details in GUI error messages or display them
    in a more readable way, see code comment.
    ryanofsky committed Feb 28, 2023
    Configuration menu
    Copy the full SHA
    d172b5c View commit details
    Browse the repository at this point in the history
  4. Deduplicate bitcoind and bitcoin-qt init code

    Add common InitConfig function to deduplicate bitcoind and bitcoin-qt code
    reading config files and creating the datadir.
    
    There are a few minor changes in behavior:
    
    - In bitcoin-qt, when there is a problem reading the configuration file, the
      GUI error text has changed from "Error: Cannot parse configuration file:" to
      "Error reading configuration file:" to be consistent with bitcoind.
    - In bitcoind, when there is a problem reading the settings.json file, the
      error text has changed from "Failed loading settings file" to "Settings
      file could not be read" to be consistent with bitcoin-qt.
    - In bitcoind, when there is a problem writing the settings.json file, the
      error text has changed from "Failed saving settings file" to "Settings file
      could not be written" to be consistent with bitcoin-qt.
    - In bitcoin-qt, if there datadir is not accessible (e.g. no permission to read),
      there is an normal error dialog showing "Error: filesystem error: status:
      Permission denied [.../settings.json]", instead of an uncaught exception
    ryanofsky committed Feb 28, 2023
    Configuration menu
    Copy the full SHA
    802cc1e View commit details
    Browse the repository at this point in the history