mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:12:38 +00:00
Add PSBT import review flow #557
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!557
Loading…
Reference in a new issue
No description provided.
Delete branch "psbt-import-operations"
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?
Import a PSBT that we can fully sign and move to the SendReivew page. PSBT requiring a signature we can't provide is not supported right now. I think that should be designed around the future multisig flows.
Also, since I was in the send popup, I added the clear form row and qmltests to validate.
tested ACK
c144a33Unit tests pass and the functional suite passes (only
qml_test_wallet_migration.pyis skipped as it needs a legacy bitcoind, unrelated to this PR)Also manually tested on regtest (Pop!_OS/COSMIC): fully-signable PSBTs route to single/multiple SendReview and broadcast + confirm at the recipient, while foreign-input and own-inputs-but-can't-sign (watch-only wallet) PSBTs both show the "unsupported" modal.
Main issue is the scaffolding code which is currently unreachable, is for #663, but its not referenced in this PR. There are also some smaller suggestions and nits.
Pre-existing issues, not introduced here (noted while testing): the import flow lands in two existing rough edges in untouched files — "View transaction" is a no-op pop-to-root (
main.qml:166), and multi-recipient sends render as N activity rows with the fee on one (activitylistmodel.cpp:177).Nit (a11y): this interactive row sets no
Accessible.name/Accessible.role. Given the mobile/assistive targets, addAccessible.role: Accessible.ButtonandAccessible.name: text.Nit: the trailing empty 18×18
Itemhas no comment — a brief note ("reserved for right-side affordance/icon") clarifies why it's here.Nit: switching the inner switch to
enabled: falsecorrectly removes the double-toggle and lets the outer Button drivechecked. Just confirm it doesn't render the switch as greyed/disabled in a way that reads as an unavailable option rather than a decorative indicator.Nit:
implicitWidth: 305/implicitHeight: + 10plus the per-rowLayout.preferredHeight: 33literals are scattered magic numbers; factoring the row height into a property would ease future tweaks.Nit:
FormatBtchardcodes the BTC unit, ignoring the user's display setting. It's currently only reached by unreachable code (buildPsbtSummary), so two paths: (1) remove it together with that code; or (2) if it's kept as #663 scaffolding or later restored, fixFormatBtcto honor the active display unit (e.g. format viaQmlBitcoinUnitswith the user's selected unit) instead of hardcoding BTC.Nit: this copies the
QByteArrayinto astd::vector<std::byte>byte-by-byte. You can span it directly (reinterpret_cast<const std::byte*>(bytes.constData())/std::as_bytes) and drop the loop.Suggestion (root cause):
m_imported_psbtis only ever.reset()(here and L1554) and never assigned a value, so every method that dereferences it (sign/broadcast/copy/save/refresh/summary) early-returns and is unreachable in this PR. This is the foundation for #663 (PSBT operations screen). Suggest referencing #663/#664 in the PR + a commit, or landing this backend together with its consumer so it's exercised.Suggestion:
file.readAll()is unbounded. A sanity size cap before reading avoids pulling an arbitrarily large file into memory.Suggestion:
fillPSBT(sign=true)runs before the cheaper rejections — multisig (L1638), standard-output (L1658), recipient cap (L1673). A multisig/non-standard PSBT is fully signed into a throwaway copy and only then rejected. Consider doing the static checks before the signing fill.Suggestion: magic number
> 25. If this mirrors theSendRecipientsListlimit, reference that constant; otherwise name it (e.g.MAX_REVIEWABLE_RECIPIENTS) so it can't drift from the real UI cap. #664 plans broader recipient sets, so naming it now makes that change a one-liner.Suggestion (unreachable, no consumer yet): #663's broadcast action. Adds untested broadcast surface until wired up.
Suggestion (unreachable, no consumer yet): #663's save action. Adds untested arbitrary-path file-write surface until wired up.
Suggestion: of these 10 new properties, only
importedPsbtError(L83) is consumed by QML — the other nine are unused (they're for the #663 operations screen).importedPsbtLoaded()keys offm_imported_psbt_mode == "draft", which is never produced, so it's always false. Either reference #663 so this reads as intentional scaffolding, or land them with their consumer.Suggestion:
signImportedPsbt/broadcastImportedPsbt/copyImportedPsbtToClipboard/saveImportedPsbtToFilehave no QML caller yet — they're the backend for #663. OnlyimportPsbtFromFile(L143) andclearImportedPsbt(L144) are used in this PR.Suggestion: this hidden
psbtAutomationPathFieldships in the release binary purely so functional tests can inject a path (consumed at L247-255). A hidden field that triggers an arbitrary-path file import in shipping QML is a smell — consider gating it behindENABLE_TEST_AUTOMATION(the bridge is already compiled conditionally) so it doesn't exist in release builds.Question: the
else→else if (recipients.count === 1)change is needed so import doesn't add an extra recipient on top of populated ones — good, but the rationale isn't obvious; a one-line comment would help. Iscount === 1the right guard if the list could ever be at 0?Suggestion: good end-to-end coverage. Worth adding: corrupt/undecodable PSBT, the base64-armored fallback path (walletqmlmodel.cpp:1582), file-open failure, the >25 recipient cap, and the own-inputs-but-can't-sign rejection (walletqmlmodel.cpp:1644) — I verified that last one reachable via a watch-only wallet.
We can close this in favor of https://github.com/bitcoin-core/gui-qml/pull/750
@epicleafies Can you move the review to #750 ? Sorry for the trouble.