Add PSBT import review flow #557

Closed
johnny9 wants to merge 5 commits from psbt-import-operations into qt6 AGit
johnny9 commented 2026-04-26 04:20:21 +00:00 (Migrated from github.com)
Screenshot from 2026-04-26 00-21-06 Screenshot from 2026-04-26 00-22-06

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.

<img width="819" height="698" alt="Screenshot from 2026-04-26 00-21-06" src="https://git.fish.foo/attachments/f4202520-1440-4ea8-9a1b-9385e69e569f" /> <img width="819" height="698" alt="Screenshot from 2026-04-26 00-22-06" src="https://git.fish.foo/attachments/1f5c9fc5-b347-47a0-81af-ac186146ddb0" /> 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.
epicleafies (Migrated from github.com) reviewed 2026-06-08 04:16:43 +00:00
epicleafies (Migrated from github.com) left a comment

tested ACK c144a33

Unit tests pass and the functional suite passes (only qml_test_wallet_migration.py is 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).

tested ACK c144a33 Unit tests pass and the functional suite passes (only `qml_test_wallet_migration.py` is 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`).
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Nit (a11y): this interactive row sets no Accessible.name / Accessible.role. Given the mobile/assistive targets, add Accessible.role: Accessible.Button and Accessible.name: text.

Nit (a11y): this interactive row sets no `Accessible.name` / `Accessible.role`. Given the mobile/assistive targets, add `Accessible.role: Accessible.Button` and `Accessible.name: text`.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Nit: the trailing empty 18×18 Item has no comment — a brief note ("reserved for right-side affordance/icon") clarifies why it's here.

Nit: the trailing empty 18×18 `Item` has no comment — a brief note ("reserved for right-side affordance/icon") clarifies why it's here.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Nit: switching the inner switch to enabled: false correctly removes the double-toggle and lets the outer Button drive checked. 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: switching the inner switch to `enabled: false` correctly removes the double-toggle and lets the outer Button drive `checked`. 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.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Nit: implicitWidth: 305 / implicitHeight: + 10 plus the per-row Layout.preferredHeight: 33 literals are scattered magic numbers; factoring the row height into a property would ease future tweaks.

Nit: `implicitWidth: 305` / `implicitHeight: + 10` plus the per-row `Layout.preferredHeight: 33` literals are scattered magic numbers; factoring the row height into a property would ease future tweaks.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Nit: FormatBtc hardcodes 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, fix FormatBtc to honor the active display unit (e.g. format via QmlBitcoinUnits with the user's selected unit) instead of hardcoding BTC.

Nit: `FormatBtc` hardcodes 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, fix `FormatBtc` to honor the active display unit (e.g. format via `QmlBitcoinUnits` with the user's selected unit) instead of hardcoding BTC.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Nit: this copies the QByteArray into a std::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.

Nit: this copies the `QByteArray` into a `std::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.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Suggestion (root cause): m_imported_psbt is 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 (root cause): `m_imported_psbt` is 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.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Suggestion: file.readAll() is unbounded. A sanity size cap before reading avoids pulling an arbitrarily large file into memory.

Suggestion: `file.readAll()` is unbounded. A sanity size cap before reading avoids pulling an arbitrarily large file into memory.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

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: `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.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Suggestion: magic number > 25. If this mirrors the SendRecipientsList limit, 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: magic number `> 25`. If this mirrors the `SendRecipientsList` limit, 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.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Suggestion (unreachable, no consumer yet): #663's broadcast action. Adds untested broadcast surface until wired up.

Suggestion (unreachable, no consumer yet): #663's broadcast action. Adds untested broadcast surface until wired up.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Suggestion (unreachable, no consumer yet): #663's save action. Adds untested arbitrary-path file-write surface until wired up.

Suggestion (unreachable, no consumer yet): #663's save action. Adds untested arbitrary-path file-write surface until wired up.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

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 off m_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: 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 off `m_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.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Suggestion: signImportedPsbt / broadcastImportedPsbt / copyImportedPsbtToClipboard / saveImportedPsbtToFile have no QML caller yet — they're the backend for #663. Only importPsbtFromFile (L143) and clearImportedPsbt (L144) are used in this PR.

Suggestion: `signImportedPsbt` / `broadcastImportedPsbt` / `copyImportedPsbtToClipboard` / `saveImportedPsbtToFile` have no QML caller yet — they're the backend for #663. Only `importPsbtFromFile` (L143) and `clearImportedPsbt` (L144) are used in this PR.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

Suggestion: this hidden psbtAutomationPathField ships 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 behind ENABLE_TEST_AUTOMATION (the bridge is already compiled conditionally) so it doesn't exist in release builds.

Suggestion: this hidden `psbtAutomationPathField` ships 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 behind `ENABLE_TEST_AUTOMATION` (the bridge is already compiled conditionally) so it doesn't exist in release builds.
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

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. Is count === 1 the right guard if the list could ever be at 0?

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. Is `count === 1` the right guard if the list could ever be at 0?
epicleafies (Migrated from github.com) commented 2026-06-08 03:42:43 +00:00

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.

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.
pseudoramdom commented 2026-06-08 04:18:10 +00:00 (Migrated from github.com)

We can close this in favor of https://github.com/bitcoin-core/gui-qml/pull/750

We can close this in favor of https://github.com/bitcoin-core/gui-qml/pull/750
pseudoramdom commented 2026-06-08 04:18:57 +00:00 (Migrated from github.com)

We can close this in favor of #750

@epicleafies Can you move the review to #750 ? Sorry for the trouble.

> We can close this in favor of #750 @epicleafies Can you move the review to #750 ? Sorry for the trouble.
Sign in to join this conversation.
No description provided.