mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:12:38 +00:00
feat: watch-only exporting for wallets #1057
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml!1057
Loading…
Reference in a new issue
No description provided.
Delete branch "wallet-export-xpub"
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?
According to https://johnny9.dev/bitcoin-gui-evidence/#feature/F05, the watch-only exporting option is missed in the QML version. this pr is implementing it by adding a new option inside wallet settings to be able to export a watch-only wallet by sharing the descriptor or the extended public key.
the user would be able to scan it by QR, copy it, and save it to a file. both for the descriptor and xpub
Screenshots
I'm testing this PR on Windows. “Save to file” opens in the application's working directory. Could we explicitly set
currentFolderand construct both URLs withQUrl::fromLocalFile()? TheQFileDialogwrapper also needsselectFile()for local file preselection before the native dialog opens.Encrypting an existing wallet generates a new HD seed and makes the previous descriptors inactive, but those descriptors can still hold funds. Exporting only active descriptors therefore makes “Complete watch-only wallet” incomplete: it can miss funds received before encryption. Could we include the relevant inactive descriptors and add a regression test with funds received before encryption?
On Windows, the focus outline around “Address type” is clipped at the top and sides (see screenshot).
ListRowdraws the outline outside its bounds, while the enclosingFormSectionclips it. Could we keep the full focus outline visible here?I found a race on Windows when opening the export while another wallet is loading:
After B finishes loading and becomes selected, the popup can remain open with A’s descriptors. In my testing, skipping step 3 makes the popup close normally.
This seems to happen when the wallet changes during the enter transition, while
openedis still false. Could we checkvisibleinstead to cover that interval?Reviewed
71947071a5. I think the dialog looks good. I found an additional issue with extended-key export. I also reproduced the four issues already reported by ValeraFinebits.When the receive and change descriptors use different xpubs, “Extended key” exports only the receive key, so the imported wallet misses change funds. I reproduced 99.9999859 BTC in the source wallet versus 50 BTC after import. Disable this format when one key cannot represent both descriptor branches, and extend
watchOnlyExportsJoinReceiveAndChangeto cover this case.Review failed for
780a6a245a3c. The review did not finish successfully. No findings are published for this attempt.Attempted head:
780a6a245a3c· Attempt reportPrevious completed review:
598abdbeb3a5I don't think we should be showing descriptors for each output type unless someone is planning to export to a non-BitcoinCore wallet.
The right way to do it would be to export to a file which the BitcoinCore v32.1 GUI &
exportwatchonlywalletRPC does.Saving descriptors as text loses metadata such as creation times, ranges, and next indices. It also omits transactions, labels, wallet flags, and the best-block locator that can avoid a rescan when the wallet is restored.
We should also use interfaces::Wallet::exportWatchOnlyWallet(destination) for this flow.
Showing descriptors for each output type seems more appropriate for a separate flow intended for importing into other wallets. Maybe we can avoid this flow and such users can use the RPC instead?
Agreed for Core to Core, the file keeps birth times, labels and the best-block locator, and our Import flow already restores it through
restoreWallet. Our submodule doesn't haveexportWatchOnlyWalletyet though (bitcoin/bitcoin#32489 landed afterdc282ff31d), so this needs a bump first. Should I do the bump here or wait for a separate one?For other wallets I'd still keep the descriptor/xpub view, but as a separate action. Most GUI users won't use the RPC, especially on mobile. WDYT?
Updates about the flow and the design
Instead of "Export watch-only wallet" option that shows the descriptor and the xpubs, now there's "Descriptors" option and we moved exporting the wallet it self to "Backup or Export wallet" option:
Now, if you go to "Backup or Export wallet", you will would be able to export a full backup with private keys or view-only wallet that contains the public keys only:
if you go to "Descriptors", you will see the the descriptors and would be able to copy all of them as json format like that:
or would be able to copy specific type:

also, you can get the extended public keys for different address types

Reviewed
fc657610b8. I independently confirmed two findings already identified by rreview:descriptorExports()omits the change descriptor and can still enable extended-key export. This can produce a watch-only view that misses change funds. Confirmed by tracing the parser and export logic against Core's independently activated receive/change managers.These confirm rreview's existing findings rather than adding new ones: GitHub summary and run archive (
adversarial:2for the unsupported-change finding).