mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:00:39 +00:00
qml: Stabilize onboarding settings and data directories #883
No reviewers
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml!883
Loading…
Reference in a new issue
No description provided.
Delete branch "onboarding-settings-combined"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This combines #812 by @jarolrod with #864 and the review fixes for #812. Jarol's original commit keeps its authorship.
Pre-init onboarding was reading config and settings through the live
gArgs, then normal startup read them again. A redirected data directory could make the second read use a different profile. GUI reset also ran before Core knew the active data directory and network.This change builds the onboarding preview with a scratch
ArgsManager. It keeps the selected data directory separate from the profile resolved by Core, then applies settings afterInitConfig()and chain-specificQSettingssetup. Canceling onboarding does not change settings.Fixes
Reset now uses the final Core settings precedence, treats
-resetguisettings=0as false, preservesstrDataDir, and backs up both Core and GUI settings. If a later write fails, it restores the earlier state. For malformedsettings.jsonfiles, the backup keeps the original bytes. Settings stores are opened only when needed, and an apply is rejected if its target profile changed while onboarding was open.User-facing startup errors and translator context are included.
The Settings-page reset and
bitcoin.confactions tracked by #600 remain separate work.The review follow-up also catches inaccessible config-selected profiles, treats obsolete legacy-key cleanup as best effort during ordinary startup, reads absolute configuration/includes for new-folder previews, and saves malformed settings bytes before Core can replace them. It creates custom settings parents before
InitConfigand preserves explicit listen-off choices while enabling a proxy.Tests
Latest review fixes at
976e00e4826c: accept existing writable data directories under read-only parents, validate blocks directories before locking, preserve explicit NAT-PMP opt-outs, keep GUI preferences during settings-file recovery, and resolve relative configuration files during new-folder previews. A fresh native build, all 182 focused settings tests (zero skips), and six startup-error scenarios pass. Original-source negative controls reproduce all five findings. Sanitizers were not rerun for this revision.Earlier validation follows; its sanitizer and CI qualifications still apply.
Validation at
e66868e449c6:The GUI sanitizer runs need the independently reproduced Qt hash-wrap exception and keep libdbus resident to avoid its process-global allocation report. The offscreen SIGINT case also needs specific FreeType allocation exceptions: a Qt-only control reproduces exactly 2248 bytes/28 allocations after application-font registration, while an unrelated 137-byte application leak still fails. These exceptions are local validation files, not repository or executable-wide suppressions. This is qualified sanitizer coverage, not a clean default-environment CI pass.
The standalone GUI checkout lacks the requested top-level lint/tidy/sanitizer CI drivers. Core-only fallback runs are partial and do not establish a full GUI-QML CI pass. The IPC-enabled standalone GUI uses a local-node factory, so Core multiprocess IPC lifecycle remains uncovered and
interface_gui.pyis absent. Earlier CI run.Fixes #773
Fixes #774
Fixes #775
Fixes #783
Fixes #846
Please rebase.
rebased
🟠 Minor · Onboarding drops an explicit NAT-PMP opt-out when listening is disabled
On a fresh profile, disabling NAT-PMP together with listening or enabling a proxy loses the explicit NAT-PMP preference, allowing default-enabled port mapping to return after the disabling condition is removed.
Location:
qml/onboarding_settings.cpp:731(head).🟠 Minor · An unwritable config-selected data directory no longer opens the chooser
A readable, onboarded profile selected by bitcoin.conf can skip the chooser despite an unwritable data directory, causing startup to fail instead of offering a replacement location.
Location:
qml/onboarding_settings.cpp:1011(head).🟠 Minor · The settings-recovery dialog ignores application Quit events
While the recovery dialog is open, QmlQuitHandler consumes application Quit events without dismissing the dialog, leaving startup waiting for a manual Reset or Abort.
Location:
qml/bitcoin.cpp:375(head).🔵 Suggestion · Settings-file recovery also resets unrelated GUI preferences
Choosing Reset for an unreadable settings.json also clears active GUI preferences and legacy settings, although the prompt matches bitcoin-qt's narrower settings-file recovery.
Location:
qml/onboarding_settings.cpp:1192(head).🔵 Suggestion · New-folder preview skips an explicit relative configuration file
An explicit relative -conf is skipped during new-folder preview but loaded after confirmation, potentially causing an inaccurate preview or a misleading profile-change rejection.
Location:
qml/onboarding_settings.cpp:263(head).Review coverage was incomplete.
Reviewed:
e66868e449c6· Full review report · Previous reportspermalink
1 additional verified finding in the Review report.
🔴 Major · Startup-error test driver leaves onboarding alerts undetected and undismissed
Source inspection shows that the held-directory and two blocksdir cases have no alert-dismissal path, so they reach the 30-second subprocess timeout and fail the new CI test.
Location: test/test_startup_errors.cpp:31 (head).
🟠 Minor ·
-noconfblocks onboarding with a new data folderWith
-noconf, choosing a folder that does not yet exist, including a missing saved folder, produces a configuration preview error and prevents onboarding from finishing.Location: qml/onboarding_settings.cpp:285 (head).
🟠 Minor · Legacy cleanup rollback can reverse default-valued onboarding choices
With mixed writable and read-only legacy stores, cleanup rollback can restore an obsolete value and reverse a default-valued onboarding choice on restart; occurrence in production is unconfirmed.
Location: qml/legacy_settings_migration.cpp:253 (head).
🟠 Minor ·
-resetguisettingsresolves and locks the blocks directory before clearing itFor manually or externally added
blocksdirvalues,-resetguisettingscan fail on the discarded path or keep it cached for the session; no current GUI/Core caller writes this setting.Location: qml/bitcoin.cpp:739 (head).
🟠 Minor · New-folder preview ignores existing data in explicit external directories
A missing custom folder is classified as fresh despite populated explicit
-blocksdiror-walletdirpaths, changing storage requirements and automatic prune recommendations; production frequency is unknown.Location: qml/onboarding_settings.cpp:1191 (head).
🟠 Minor ·
choosedatadir=1inbitcoin.confno longer opens onboardingFor an onboarded usable profile without a command-line
-datadir,choosedatadir=1inbitcoin.confis ignored because the chooser request is captured before configuration parsing.Location: qml/onboarding_settings.cpp:1062 (head).
Review coverage was incomplete.
Reviewed:
38ddfedfe692· Review reportFixed all six findings in
e66868e449. Startup opens the chooser for an inaccessible config-selected directory and tolerates obsolete-settings cleanup failures during ordinary startup. New-folder previews read absolute config files and includes. Reset saves malformed settings bytes before Core replaces the file, and onboarding creates custom settings parents before startup writes them. Explicit listen-off choices survive enabling and later removing a proxy.Added unit and GUI regressions; the original code rejects all six unit controls and the nested-settings GUI control. Native C++ tests pass (912 passes, 10 existing skips), all 173 focused settings tests pass, and onboarding/reset/startup/shutdown GUI checks pass. A fresh LLVM 22 sanitizer build passes all 173 focused tests with strict Core options.
GUI sanitizer lifecycle also passes with documented Qt dependency qualifications: the independently reproduced hash-wrap exception, resident libdbus, and specific FreeType allocation exceptions for the offscreen SIGINT case. Qt-only controls reproduce those allocations; an unrelated 137-byte application leak still fails. No repository or executable-wide suppression was added.
Matching LLVM 22/Bitcoin-plugin checks and Ruff pass. The standalone GUI CI drivers are absent and Core-only fallback runs remain incomplete, and actual Core multiprocess IPC lifecycle is not covered by this standalone local-node GUI. New CI run.
Correction to the earlier CI note: configured rootless Docker is available outside the restricted sandbox. Core-only fallback driver attempts do not cover parent GUI-QML changes.
Additional CI follow-up in
ae2b20394c: the inherited custom-fee test required exact equality with the final signed transaction size. Pinned Core reproduced a 141-sat fee with a 140-vB transaction after a shorter ECDSA signature, so this was a test defect. The test now uses Core's bounded fee assertion and retains the wallet-minimum override and relay-minimum rejection checks. Shared-path validation passes eleven fee-boundary controls and both instrumented GUI fee scenarios. Only the Python test changed in this follow-up; earlier sanitizer/driver/IPC qualifications remain unchanged. New hosted checks are queued or running on this revision; no result is claimed yet. A freshly rebuilt native application for this PR also passes both GUI fee scenarios.One early startup exception remains outside this PR’s error handling: conflicting command-line network selections.
With an existing disposable data directory, launching
bitcoin-core-appwith-regtest -testnetaborts before opening a window. On mergedqt6at6e54a48ab571, stderr reports an uncaughtstd::runtime_errorexplaining that at most one network can be selected. The equivalentbitcoindinvocation reports the configuration error and exits with status 1.At this PR’s current head,
8e5b4d1f090a, the earlysetupChainQSettingscall still evaluatesgArgs.GetChainTypeString()before the guarded configuration preview andInitConfig.Please catch this early exception and show the normal startup error, with a regression covering conflicting command-line network flags.
Reproduced on the merged build, macOS / Qt 6.9.0. The current PR was checked in source; its binary was not runtime-tested.
One more case for the settings-before-startup ordering: the wizard's choices are written into a data directory that another running node holds, and the lock failure comes afterwards.
To reproduce at
eed1f426fcb6:bitcoindon a regtest data directory B that is a full node, and leave it running.Cannot obtain a lock on directory B/regtest. Bitcoin Core is probably already running.B's
settings.jsonhas already been rewritten with"prune": "1907"and"qml_onboarded": true, about 0.05 s after Start and before the lock error. The running node is not disturbed, but what happens next depends on it:bitcoindcame back withpruned=truewhere it had been a full node.createwalletwithload_on_startup=true, it replaces the file from memory, the keys are gone, and the wizard returns on the next launch.With
bitcoindstopped first, the same clicks start the app normally. A second app instance as the holder gave the same result asbitcoind.Writing
settings.jsonbefore the lock is not unusual in itself. Core'sInitConfigrewrites the file before locking, and Bitcoin-Qt stores its intro choice beforebaseInitialize. The gap here is that a changed choice is committed to another node's directory and stays there after the start has been reported as failed.By source, the order is the same at
b4ec1efcec60:FinalizeStartupSettingsapplies the pending choices beforenode->baseInitialize()takes the lock (bitcoin.cpp#L688-L705). I have not run this branch. Restoring the settings snapshot whenbaseInitializefails, or checking the lock before applying the choices, would cover it.This is narrow: it needs a held directory, a changed choice and a restart of the holder before its next settings write. Only the storage choice was run; by source any setting changed in the wizard is written the same way.
Reproduced on merged
qt6ateed1f426fcb6, macOS / Qt 6.9, isolated regtest, offscreen and native. The directory was passed to the model with the call the folder dialog makes, and the other steps were clicks through the test bridge. The lock error was read from stderr; the error window was not inspected.I ran this branch at
b4ec1efcec60against mergedqt6ateed1f426fcb6(same Core), using the startup and data-directory cases I had reported earlier.Fixed on this branch
bitcoin.confleft inside a redirected data directory, or an unwritable data directory, merged exits 1 with no window and nothing on stderr. This branch reports Core's error and stays running. Through the first-run wizard, merged had already savedqml_onboardedbefore failing, so every later launch failed silently too; here nothing is saved and the wizard returns on the next launch.-datadirthat does not exist, absolute or relative. Merged aborts onAssertion failed: (base.is_absolute()); this branch reportsSpecified data directory "…" does not exist.-resetguisettingsbackup from #1073. After the reset,settings.json.bakkeeps the originalpruneanddbcachevalues, and nothing is touched until Start.Still present
-regtest -testnetstill aborts before any window with the uncaughtstd::runtime_error, as in my earlier comment.settings.jsongains"prune": "1907"and"qml_onboarded": trueabout 0.04 s after Start, the lock error follows, and the other node comes back pruned after a restart.Two cases that now end in the wizard with no way forward
bitcoin.confagainst a launch flag (testnet=1in the file,-regteston the command line). Merged aborts. This branch opens the first-run wizard, also for a profile that is already onboarded, withInvalid combination of -regtest, -signet, -testnet, -testnet4 and -chain. Can use at most one.drawn over the Next button. On Storage amount, Next never enables and Store all data reads "Uses about 0GB". The startup error would fit better here.datadir=inbitcoin.confpointing at a missing folder. The wizard opens, and its Storage location page has Custom checked, the error shown and Next disabled. Clicking Default selects it, but the error stays and Next stays disabled. I did not try choosing another Custom folder.In both, the error text in the footer overlaps the Back and Next buttons.
I saw no regression against merged in these runs.
Tested on macOS / Qt 6.9, isolated regtest, offscreen, with native runs for the config-failure, two-flag, held-directory, missing-
-datadirand both wizard cases; the-resetguisettingscase was offscreen only. The startup error window has no test hook, so its text is from stderr and I did not see the window itself. Wizard steps were clicks through the test bridge; the held-directory Custom folder was passed with the call the folder dialog makes, and onboarded profiles were set up with-qml_onboarded=1or a preparedsettings.json.I re-ran my cases at
976e00e4826cand read through the whole change. Everything my review above listed as open is fixed, and the direction is right.Three things introduced on this branch should be fixed before it merges. Each has an inline comment marked To fix before merge: the early return that keeps
-choosedatadirand-resetguisettingsfrom reaching the wizard, the network folder for a custom signet, and the legacy store that cannot be written. Each is confirmed by running it on this head and on mergedqt6ateed1f426fcb6. The other inline comments are smaller and not blocking.Not tied to a line
d384f906f6,onboarding_settings.cppcallsShouldShowDataDirChooser(preview_args)with one argument against a two-argument declaration, anda59a0c8d41is the first commit where that call is gone. By source; I did not compile each commit.bitcoin.conf.bitcoindprefixes it withError reading configuration file:.Already on
qt6, not asking for these heretxindex=1set, choosing Reduce storage in the wizard savespruneandqml_onboarded, then fails withPrune mode is incompatible with -txindex.Every later launch repeats the error with no wizard.-datadir=X, Storage location accepts another folder and shows it with no error, and the node then runs in X.[regtest],vbparams=bogus) shows onlyThe selected directory could not be checked.The first two were re-run at this head; the other two at
a952c1616a12.Confirmed at this head
-blocksdirreportsSpecified blocks directory "…" does not exist.from a writable or a read-only working directory and leaves no.lockbehind. Ata952c1616a12the early lock created a.lockin the working directory, or failed withCannot write to directory ''. The wizard also no longer savespruneandqml_onboardedbefore that error.-datadir, fromdatadir=or from the saved selection.-confis read from the folder chosen in the wizard, and the preview agrees with what Start does.bitcoin.confagainst a launch flag,datadir=pointing at a missing folder, and a data directory another node holds. So are the config-step failures, a-datadirthat does not exist and the-resetguisettingsbackup.blocksdirectory starts, and an onboarded profile starts with no wizard.Run at
a952c1616a12againstb4ec1efcec60, and not re-run here:-choosedatadirwith an unreadablesettings.jsonnow opens the wizard and leaves the file untouched; an external-settingsfile is reflected in the wizard's preview, where before the wizard showed Store all data and the node then started pruned; and a quit request during settings recovery on the wizard path now exits 0. The footer error no longer overlaps Back and Next.I could not test two changes: recovering an unreadable
settings.jsonno longer counting as a settings reset, which needs the Reset answer, and the port-mapping choice.Tested on macOS / Qt 6.9, isolated regtest, plus an offline custom signet. The escape-flag and blocks-directory cases and the cases from my first review ran offscreen and in a native window; the rest ran offscreen only. The startup error window has no test hook in the app, so its text is from stderr and I did not see the window itself. Wizard steps were clicks through the test bridge, Custom folders were passed with the call the folder dialog makes, and onboarded profiles and saved folders were set up with
-qml_onboarded=1or prepared settings files. The quit request was the test bridge's in-process quit event, not Cmd+Q. Ata952c1616a12, 770 unit and integration tests passed locally and one failed because I skipped a class it depends on; I did not run the QML test binary or eight unit test classes, which use the native settings store without a redirect.To fix before merge. With
-choosedatadiror-resetguisettings, this returns before the wizard can open.With a Custom folder saved by the app and an unparsable line in its
bitcoin.conf(I used-prune=550), this head reports the parse error with either flag and opens no wizard.b4ec1efcec60andqt6open the wizard, and another folder can be chosen and started. Those two flags are the way out of a broken saved folder, so I think the startup error should be kept for a launch without them.Run at this head, offscreen and in a native window.
Not blocking.
GetBlocksDirPath()also creates the directory, and it throws if<datadir>/regtest/blocksis a regular file or a dangling symlink, for example a link to a drive that is not mounted. On an ordinary start nothing catches that here, so the app aborts on the uncaughtfilesystem_errorwith no window.qt6aborts the same way from a later line, so this is not new, but this check is now where it throws.bitcoindexits with a message.87de04b7b4is titled "Support folder dialog with Qt 6.2", but it adds only these two lines and a test against the mock dialog, andAppFolderDialog.qmlis unchanged fromqt6. Is the title still right?Will
lupdatepick these up? The comment sits in front ofDataDirTr(), which wrapsQCoreApplication::translate, and I don't thinklupdatetreats a wrapper as a translation call, so the string and its comment may not be extracted. By source only; I did not runlupdate.To fix before merge. If the Bitcoin-Qt settings file cannot be written, this fails the whole startup.
With the legacy file read-only, or its folder, finishing the wizard and
-resetguisettingsboth stop withLegacy GUI settings migration failed for … Legacy settings rollback failed for …on every attempt, and no node starts.qt6completes and leaves the file untouched. I think a legacy store that cannot be tidied should not stop the node from starting.Run with INI files in a test settings directory only. On macOS the legacy reader opens a different preference domain (#1076), so this does not arise there today.
Not blocking. With
-datadir=given an empty value and a new Custom folder chosen, the first Start ends with this message although nothing changed while onboarding was open. A retry with the same folder then runs the node in the default folder with no message, which is whatqt6does on the first attempt.To fix before merge. This maps the chain name to a folder itself, and a custom-challenge signet does not use
signet/.A first run with
-signet -signetchallenge=51createssignet/walletsand nothing else insignet/, while the realsignet_54d26fbd/gets nowalletsfolder.qt6andbitcoindcreatesignet_54d26fbd/wallets. Asking Core for the network directory would avoid keeping a second table here.Smaller, same lines: a wizard Start that then fails at the config step leaves the empty
walletsfolders behind (seen ata952c1616a12).Not blocking.
status.active_data_dirhas been throughNormalizeLocalPath, which trims, so for a data directory whose name really ends in a space this tests a different path.A profile onboarded on
qt6gets the wizard again until it is finished once, and Start then creates a sibling folder with the trimmed name, holding onlywalletsfolders.Not blocking. When the external
-settingsfile is unreadable, this error shows on every wizard page and Next stays disabled whichever folder is chosen, since the path does not depend on the folder. The wizard offers no Reset, so the only way on is to quit and fix the file. Atb4ec1efcec60the same set-up went on to the Reset / Abort question, going by its stderr.There is a similar dead end with
-choosedatadirand an unreadablesettings.jsonwhen the user keeps that folder: Next is disabled on Storage amount.Seen at
a952c1616a12; not re-run at this head.Cosmetic. With a three-line error, the reserved space shortens the page enough that the second copy of the message, under the Custom card on Storage location, is cut off after its first line. The footer copy is complete. Seen at the default window size at
a952c1616a12.No CI job builds this target. It needs
BUILD_APP_TESTSandENABLE_TEST_AUTOMATIONtogether, and the workflows set one or the other.At
a952c1616a12I built it locally on macOS and its four cases passed, onminimaland in a native window. I have not built the two cases added since.Fixed in
e91c5b6686. With-choosedatadiror-resetguisettings, a saved folder whose profile cannot be read now opens the wizard, so another folder can be chosen. A launch without either flag still reports the error. A unit test covers both flags with an unparsablebitcoin.conf.Fixed in
e91c5b6686. The preview asks Core for the network directory name (CreateBaseChainParams(...)->DataDir()).-signet -signetchallenge=51now createssignet_<hash>/walletsand nosignet/folder. A unit test covers the custom signet. Emptywalletsfolders left after a failed config step are not changed here.Fixed in
4a4c99fb92. A legacy store that cannot be cleaned up is only logged now, for the wizard and for-resetguisettingsas well. The Core and GUI values are already written, and the old keys never override them. The read-only store test now expects startup to continue with the wizard's choices saved and the legacy file unchanged.Fixed in
38ddfedfe6. The blocks directory check catchesfs::filesystem_errorand reports it throughInitError, so the app exits with a message instead of aborting.Confirmed:
lupdateskipped the strings behindDataDirTr(). Fixed in03c0eba544by callingQCoreApplication::translate("DataDirectory", ...)directly.lupdateonqml/datadir.cppnow extracts the 14 strings with their translator comments.Fixed in
e91c5b6686. The GUI functional workflow now configures with bothBUILD_APP_TESTSandENABLE_TEST_AUTOMATION, buildsbitcoinqml_startup_error_tests, and runs it under xvfb.--no-tests=errormakes an empty selection fail.The title was wrong. The commit is now
b1211a991a, "qml: register AppSettings and AppFolderDialog in the controls module", with a body that describes the qmldir entries and the mock contract test.