feat: watch-only exporting for wallets

bitcoin-core/gui-qml: PR #1057

3 minor findings · 5 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · Watch-only import JSON includes rejected unused() entries

For wallets previously modified with addhdkey, “Copy all for Bitcoin Core” includes an unused() entry that watch-only import rejects; no GUI path creating these descriptors was found.

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

Details and suggested fix

addhdkey requires an unlocked wallet with private keys and stores an unused(<xprv>) descriptor. ExportDescriptors(..., false) includes its public form. The new filter accepts it because Expand(0, ...) succeeds even though UnusedDescriptor produces no scripts and reports HasScripts() == false. Following the GUI's instruction to import the JSON into a wallet without private keys therefore produces “Cannot import unused() to wallet without private keys enabled” for that entry. Other entries can succeed, and the rejected entry covers no addresses, but the batch is not entirely import-ready. Exclude parsed descriptors without scripts, separately from the omission count described as requiring private keys for derivation. Add a round-trip case containing normal active descriptors plus an addhdkey key.


Link

[minor] · Exhausted descriptor ranges produce rejected import JSON

With -keypool=1, copying descriptors after issuing an address can produce JSON that importdescriptors rejects with “next_index is out of range”.

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

Details and suggested fix

GetNewDestination() calls TopUp() before IncIndex(). With a keypool size of one, issuing an address can therefore leave next_index equal to the exclusive range end. descriptorImportJson() copies that index alongside an inclusive end of info.range->second - 1, so Core rejects the affected entry and the destination watch-only wallet does not import its addresses. Copying again does not refill the range. The default keypool of 1000 does not exhaust this way, and the wallet-file export tops up before exporting. For publicly expandable descriptors, ensure the exported inclusive range contains next_index without moving the index backwards, and add a round-trip test using an exhausted range.


Link

[minor] · Legacy extended-key export lacks a script-type warning

Importing the Legacy page's bare xpub/tpub through this app's existing watch-only flow creates wpkh rather than pkh descriptors, so the wallets track different addresses without a warning.

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

Details and suggested fix

Slip132ExtendedKey() returns the unchanged key for Legacy, and descriptorExports() offers it when the receive and change branches are /0/* and /1/*. The app's existing createWatchOnlyWallet() accepts that key but always installs wpkh descriptors. The resulting watch-only wallet does not show the source's pkh balance and can issue addresses the source wallet does not watch. The source still holds the corresponding private keys. A bare xpub is conventional for Legacy elsewhere, so keep that export format, but extend the warning to explain that this app's importer assumes native SegWit. The current banner only appears for Taproot.


Optional improvements

Link

[suggestion] · Single-type shortcut hides Core JSON export and the privacy note

Wallets with one displayed address type and no previous keys open the detail page directly, making “Copy all for Bitcoin Core” and the descriptor-sharing privacy note unavailable.

Location: qml/pages/wallet/WalletSettingsStack.qml:43 (head).

Details and suggested fix

openDescriptors() skips WalletDescriptors when exports.length === 1 && inactive.length === 0. Only that list page exposes descriptorImportJson(), which preserves timestamps, ranges, activity flags and next_index, and explains that sharing descriptors reveals addresses and transactions. The detail page offers QR and descriptor/key copying but neither of those features. This includes wallets created by the app's own xpub importer, which installs one wpkh receive/change pair. A single displayed type also does not exclude additional descriptors outside the single-key display filter. Keep the shortcut, but expose the Core JSON action and privacy note on the detail page too, preferably through a shared component.


Link

[suggestion] · The PR description still promises descriptor and key file saving

The description advertises saving the selected descriptor or extended key to a file, but the final UI only copies those values; its file export writes a whole wallet database.

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

Details and suggested fix

The original WatchOnlyExportModal used saveWatchOnlyExport() and a .txt dialog. Commit cb88f9ad deliberately removes that modal and writer. At head, WalletDescriptorDetail offers QR and clipboard sharing, while BackupWalletPopup saves a full backup or watch-only wallet database. Update the PR description and screenshots to distinguish database export from descriptor/key text-file saving. If text-file saving remains intended, restore an action that saves the currently selected payload instead.


Link

[suggestion] · Descriptor footer overstates receive/change coverage

Imported receive-only and unpaired previous-key descriptors contradict the footer's receive-and-change claim; no common production path creating these layouts was found.

Location: qml/pages/wallet/WalletDescriptors.qml:89 (head).

Details and suggested fix

descriptorExports() returns the receive descriptor alone when no change manager exists, and inactiveDescriptorExports() appends unpaired descriptors individually. The tests include both layouts, but the footer always says “Each descriptor covers receive and change addresses.” Previous-key rows also lack a detail page where users could inspect chain coverage before copying. Use neutral footer wording that does not promise both chains, or make that statement conditional on every listed export covering both.


Link

[suggestion] · Tr() hides destination errors from lupdate

The destination errors in walletfiledestination.cpp use an unrecognized Tr() wrapper, so normal lupdate extraction cannot make them available for translation.

Location: qml/walletfiledestination.cpp:16 (head).

Details and suggested fix

Tr(text) calls QCoreApplication::translate("WalletFileDestination", text) with a variable, while the literal messages appear only at calls to the custom wrapper. No tr-function-alias is configured for it. This affects the empty-path, missing-folder, existing-folder and protected-wallet-folder errors displayed by the backup sheet. Call QCoreApplication::translate() with the literal at each error site, keeping the translator comment beside it, so the standard extraction path can discover these messages.


Link

[suggestion] · Early commits refine a modal that the series deletes

Unless retaining the UI design history is intentional, reorganizing the first seven commits would avoid reviewing a modal and tests that disappear before the final design.

Location: qml/components/WatchOnlyExportModal.qml:12 at 6e92e35889ee (parent of cb88f9adb55b) (commit).

Details and suggested fix

06009e637e803387eea0cc800ad7cdfdb410e599 introduces WatchOnlyExportModal. The following commits adjust its save location (4e4ea96a2c1fb0fb5ffd3942e5cf2a8f61670f2c), wallet-change handling (93435fb22cdc8dba97b98648239e05d613dfe07b), covering-key selection (1721546d19662fa4231180b553f8999853856efd), availability notifications (0f68f4a4605b47967c8e52198c96fe88dd007360) and previous descriptors (6e92e35889ee6272dba59e1e5425f332496a62ef). That last commit is the direct parent of cb88f9adb55b53440f9a886a0124d683fcbe1e80, which deletes the 439-line modal and its test in favor of the two descriptor pages.

Fold that prefix into commits organized around the surviving implementation: model helpers and unit tests first, then controls and final pages with their resources, mocks and QML tests. Keep the reusable file-dialog change with its tests as a prerequisite. Leave the wallet-file export introduced by 26ffd788dd7dff171388867114a8266f8b1cd23c and subsequent fixes separate. This preserves the resulting tree while letting commit-by-commit review follow the final design rather than the abandoned modal.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.