4 minor findings · 3 suggestions
Findings
[minor] · Import exceptions leave a dangling abort callback
A wallet-database exception destroys the wallet interface without detaching its abort callback, so clicking Cancel before the queued failure completion runs can access a destroyed object.
Location: qml/walletqmlcontroller.cpp:926 (head).
Details and suggested fix
control->attach([&wallet] { wallet.abortRescan(); }) retains a reference to the interface owned by createWalletAsync, but detach() runs only after importDescriptors() returns normally. Pinned Core can throw here, for example when writing the active descriptor fails. Unwinding destroys the interface before BackendExecutor delivers the failure through its queued connection. Until then, walletLoadInProgress remains true and the form still offers Cancel, which invokes the dangling callback. Install a qScopeGuard immediately after successful attachment, as ResumeImport already does, so every exit detaches before the interface is destroyed.
[minor] · High-start descriptor ranges trigger enormous uncancellable imports
Crafted high-start descriptor ranges, with no current producer identified, pass preflight and make the pinned backend attempt billions of uncancellable derivations, potentially exhausting memory or preventing import completion.
Location: qml/viewonlyimport.cpp:201 (head).
Details and suggested fix
For an otherwise valid ranged descriptor, "range": [2147000000, 2147483646] passes CheckDescriptorRangeBounds: its width is below one million and its endpoint is below the rejected boundary. However, a new DescriptorScriptPubKeyMan starts with m_max_cached_index = -1, and TopUpWithDB derives and caches every index from zero through the range endpoint while holding cs_wallet. Cancel only calls abortRescan(), and this installation loop never checks the scanner's abort flag. The previous xpub-only path did not accept these endpoints. Add a preflight bound on the actual derivation work, with a recoverable error, rather than relying only on the requested range width.
[minor] · Rescan progress incorrectly certifies complete descriptor installation
After a crash during a mixed-success import, recovery can clear its warning despite missing descriptors; no current listdescriptors producer of such a batch was identified.
Location: qml/walletqmlcontroller.cpp:936 (head).
Details and suggested fix
The first ShowProgress event writes installed=true, but pinned ProcessDescriptorsImport starts scanning whenever any request succeeds. For example, a valid active descriptor followed by another ranged descriptor with "range": [2147483647, 2147483647] passes GUI preflight, but Core rejects the latter because its exclusive end exceeds INT32_MAX. If interrupted during the resulting scan, a later load trusts the marker, rescans only the descriptors that exist, and removes the warning without reporting the missing descriptor. Normal completion instead detects the error and discards the wallet. Verify the complete saved descriptor set before promoting the marker; scan progress alone is insufficient.
[minor] · Import proceeds without confirming recovery-marker persistence
If GUI settings cannot be written and the app crashes during the import rescan, the wallet can reload with missing older history and neither automatic recovery nor a warning.
Location: qml/walletqmlcontroller.cpp:930 (head).
Details and suggested fix
SetPendingImport calls QSettings::sync() without checking status(), and the setup callback proceeds directly to importDescriptors(). If the settings location is unwritable or full while the wallet directory remains writable, the initial marker may never reach persistent storage. After an interruption, ReadPendingImport treats the missing start value as no pending import, while Core loads from the wallet's saved best-block locator rather than searching its older history. Return and check the persistence status, and stop with a recoverable error before importing descriptors when the initial marker cannot be stored.
Optional improvements
[suggestion] · Long import rescans block switching to other wallets
A full-history import can take hours, during which the form hides back and close navigation and walletLoadInProgress prevents selecting another wallet or adding one.
Location: qml/walletqmlcontroller.cpp:944 (head).
Details and suggested fix
importDescriptors() performs its rescan synchronously inside the wallet-creation command, so walletLoadInProgress stays true until the queued completion. The available escape from the import form is cancellation, which deletes the new wallet. Keep unrelated wallets usable during this potentially long operation by separating descriptor installation from background history recovery, following the existing separate rescan-executor pattern. That change needs an explicit cancellation contract: stopping a background scan would retain the wallet and its incomplete-history warning rather than delete it.
[suggestion] · Cancellation after the final worker check is ignored
A narrow completion race lets the form accept Cancel after the worker's last cancellation check, then show the new wallet instead of deleting it.
Location: qml/walletqmlcontroller.cpp:947 (head).
Details and suggested fix
After detach() and the single control->cancelled() check, the worker checks results, synchronizes settings, and returns success. Until the queued completion runs, the form still offers Cancel and says cancellation deletes the wallet. A click in that interval sets m_cancelled, but the abort callback is already detached and nothing reads the flag again before publishing the wallet. Make cancellation and publication share a final decision, for example by checking the control in the GUI completion and scheduling disposal instead of publication when cancellation won. The user can remove the wallet afterwards, but the current action silently fails to honor the displayed contract.
[suggestion] · Wallet backups do not carry pending import recovery state
A backup taken after an interrupted import, while history recovery is running or failed, can restore under another path with incomplete history and no recovery banner.
Location: qml/walletqmlcontroller.cpp:148 (head).
Details and suggested fix
The recovery marker exists only in QSettings, keyed by the wallet's canonical path. Neither backup caller checks historyRecovery, and pinned CWallet::BackupWallet writes the current processed tip before copying the database. Restoring that copy under another name or installation therefore starts from the saved tip without the marker that requests the older scan. Warn about or block backups while recovery remains pending, so an apparently normal backup does not silently lose the source wallet's incomplete-history status.