feat: watch-only exporting for wallets

bitcoin-core/gui-qml: PR #1057

7 minor findings · 3 suggestions

Findings

Link

[minor] · Trailing whitespace bypasses loaded-wallet overwrite protection

On POSIX, confirming Replace can overwrite a loaded external wallet whose directory ends in whitespace; no in-tree flow creating such a name was found.

Location: qml/walletqmlcontroller.cpp:237 (head).

Details and suggested fix

walletFileDestination() protects loaded and retiring wallets through walletLocationPath(), but that helper applies name.trimmed() to the backend name. Core accepts normalized absolute directories without trimming them, so a wallet loaded as /ext/wallet is protected as /ext/wallet. The destination /ext/wallet /wallet.dat retains its interior space and passes the protected-path check. After explicit Replace confirmation, WriteWalletFile() writes a sibling .partial file and renames it over the live database. On POSIX, this bypasses SQLite's exclusive database lock; the open wallet retains the old inode, while reloading opens the replacement. A watch-only replacement contains no private keys. Unlike the base SQLite backup path, the new replacement does not write through SQLite's locking mechanism. Build protected paths from the exact backend name and add a POSIX regression test using a trailing-space external wallet directory.


Link

[minor] · Taproot extended-key export carries no script-type information

A consumer defaulting plain xpub/tpub imports to P2PKH would derive addresses the Taproot wallet does not watch; specific third-party importer behavior was not verified.

Location: qml/models/walletqmlmodel.cpp:653 (head).

Details and suggested fix

Slip132ExtendedKey() returns the key unchanged for BECH32M, and descriptorExports() still enables the Extended key format for matching receive and change branches. A standard Taproot account therefore exports as an ordinary xpub/tpub. If an importer interprets that key as P2PKH, payments go to scripts derived from the Taproot account key rather than the wallet's legacy account, so they do not appear in the source wallet until the corresponding descriptor is imported manually. The current note recommends descriptor format but does not explain that an import can succeed with the wrong address type. Add an explicit warning about this outcome before copying or scanning the bare Taproot key, while preserving its use by Taproot-aware importers.


Link

[minor] · Receive-only wallets offer an extended key for an untracked change branch

Receive-only manual imports can expose an extended key implying untracked /1/* change; no in-tree flow creating this wallet layout was found.

Location: qml/models/walletqmlmodel.cpp:1382 (head).

Details and suggested fix

key_covers_both accepts !change, despite the adjacent rule that a bare key implies both /0/* and /1/*. For a wallet containing only the receive descriptor, an importer using those conventional branches can generate change that the source wallet neither recognizes nor normally signs for. Core's descriptor signing-provider lookups require known scripts or pubkeys, so possessing the ancestor private key does not repair this automatically; importing the missing change descriptor restores recognition and signing. Require a matching /1/* change descriptor before offering Extended key, while retaining the exact receive-only descriptor export. Update the existing nested-SegWit test, which currently expects an upub without a change descriptor.


Link

[minor] · Dismissing a pending export exposes wallet actions that block the GUI

Closing the backup sheet during export and opening Addresses can block the GUI thread on cs_wallet until export completes; the stall duration was not measured.

Location: qml/components/BackupWalletPopup.qml:20 (head).

Details and suggested fix

BackupWalletPopup.pending disables its save controls but never binds DialogPopup.busy, so Escape, an outside press, and the header close button remain available. After dismissal, Addresses is still enabled. Its handler calls addressListModel.refresh(), which synchronously reaches addressBalances() and listCoins() on the GUI thread. The backend export holds cs_wallet across keypool top-up and the complete watch-only export, so that action waits for the export and stops event processing. Bind busy: root.pending and disable the header close button while pending, keeping the sheet modal until the export releases the lock.


Link

[minor] · Receiving on an unused inactive descriptor leaves its export availability stale

A transaction can make an inactive descriptor eligible for display without emitting descriptorExportsChanged, leaving the Descriptors action hidden or an open list unchanged.

Location: qml/models/walletqmlmodel.cpp:3632 (head).

Details and suggested fix

inactiveDescriptorExports() includes a previous key only after GetNext() > 0. Receiving on one of its pre-derived scripts advances that index through MarkUnusedAddresses() and IncIndex(). For a publicly expandable ranged descriptor, CanGetAddresses() remains true, so the increment emits no availability notification. The GUI transaction callback also omits descriptorExportsChanged. Consequently, an open list does not acquire the previous-key row until recreated, and canShowDescriptors can remain false when no other export is available. Emit the descriptor notification from the transaction-update path and add a test that checks notification delivery when an inactive descriptor becomes used.


Link

[minor] · Backup and replacement paths can be interpreted as rich text

The new path fields inherit Text.AutoText, so markup-looking local paths can be displayed differently from the paths actually saved or replaced.

Location: qml/components/BackupWalletPopup.qml:118 (head).

Details and suggested fix

CoreText derives from Text without setting textFormat. The backup destination and error fields, plus the replacement alert's folder and filenames, therefore use Text.AutoText. Under that contract, a valid path containing a recognized tag such as a <b> directory component can be interpreted as markup rather than literal filesystem text. The writer still receives the original path, so the confirmation need not show its literal spelling. Set textFormat: Text.PlainText on these fields, as ToastBanner already does for path-bearing messages, and add a regression test using a markup-looking path. This conclusion follows from source inspection, not a rendered-UI experiment.


Link

[minor] · Backups without private keys show a spending-authority warning

Watch-only and external-signer wallet backups receive the full-backup spending warning even though their files contain no private keys; their actual exposure is balance and transaction privacy.

Location: qml/components/BackupWalletPopup.qml:93 (head).

Details and suggested fix

canExportWatchOnlyWallet() is false when private keys are disabled. startBackup() consequently hides type selection and forces backupPopup.watchOnly to false. The warning then selects one of the messages saying the file can spend bitcoin, because it checks the chosen operation rather than the wallet's private-key capability. Pass that capability separately and use the privacy warning for backups without private keys. Extend test_backup_without_private_keys_offers_only_a_backup to assert the warning as well as the hidden option and Save label.


Optional improvements

Link

[suggestion] · The per-type descriptor note omits previous-key exclusions

The detail page names the address type but does not explain that funds on previous keys of that same type are excluded.

Location: qml/pages/wallet/WalletDescriptorDetail.qml:149 (head).

Details and suggested fix

WalletDescriptorDetail.refresh() selects only the active entry from descriptorExports(). Previous keys are separate entries on WalletDescriptors, so after seed replacement during encryptwallet, copying the active Bech32 descriptor excludes funds on the old Bech32 key. The existing whole-wallet recommendation helps, but the address-type note does not identify this same-type exclusion. When inactiveDescriptorExports() contains a matching id, add a sentence saying previous keys are not included and direct users to Copy all or the watch-only wallet copy. The export behavior itself can remain unchanged.


Link

[suggestion] · Replace precedes protection of other loaded wallets in the series

The first Replace commit can replace another loaded external wallet's database; the immediately following commit supplies the broader protection, so this is an intermediate-series concern rather than that defect at head.

Location: qml/walletqmlcontroller.cpp:219 at 5d8257b21042 (commit) (commit).

Details and suggested fix

At 5f377ca8ee4824def8b4580d9825bd12bcf725c8 with parent=null, walletFileDestination() protects only walletdir and the selected wallet, while WriteWalletFile() already replaces destinations through fs::rename(). The next commit, 5d8257b2104215cb59a786f8da19afa2cb394dfe with parent=null, adds the other loaded and retiring wallet paths and walletFileDestinationProtectsOtherLoadedWallets. Fold that commit and its test into 5f377ca8ee4824def8b4580d9825bd12bcf725c8. This lets reviewers validate replacement together with its intended protection set and avoids landing on the unsafe intermediate state during bisecting, without changing the final tree.


Link

[suggestion] · The series builds and repairs a modal that it later deletes

Commit-by-commit review traverses a discarded modal and its repairs, including a test-only commit labeled as a production fix; the description still promises the removed text-file export.

Location: qml/components/WatchOnlyExportModal.qml:1 at c7006f3a059d (parent of 0a4060005a93) (commit).

Details and suggested fix

0443ea688ec5f09d0acaa55521699580b9e3234b introduces the modal, and 0a4060005a93e98276a58f467007a32c58b8e739 deletes it and introduces descriptor pages. At the latter commit's explicit parent, c7006f3a059db1f188df96d2e7d8f8deef495509, the modal still has 439 lines and a text-file save action. Meanwhile, 67d749a393c2a637f699f95d6be84de5aa60fbcb with parent=null adds only a modal focus test, although its message describes a ListRow fix already present at base. Restructure the early series to introduce the descriptor pages directly and remove modal-only changes and tests. Preserve the surviving homeFileUrl and file-dialog work from b12d016dfe7fbbb8ee607715218a7db263ac5228, extended-key and SegmentedPicker work from 11e192147d9af670680a79b5e71869ae9db931fa, notification work from 7997f65642b1cb2917475c2f33bceedbba93d3f6, and inactive-descriptor work from c7006f3a059db1f188df96d2e7d8f8deef495509, with their callers and tests adapted together. Drop the modal-only focus commit or describe it as a test addition if retained. Update the PR description to distinguish descriptor copy/QR actions from wallet-file export. This changes review flow, not the final tree.


Coverage details