Skip to content

feat(wallet): new Send screens and entry points - #1409

Open
romchornyi wants to merge 1 commit into
feat/external-send-servicesfrom
feat/external-send-screens
Open

romchornyi wants to merge 1 commit into
feat/external-send-servicesfrom
feat/external-send-screens

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1408.

Issue being fixed or feature implemented

The Send flow that pays someone outside the wallet predated the new Payments design, could pay only from Core, Shielded and Platform to Core, Shielded and Platform addresses, could not spend Identity credits and could not pay an Identity ID. This rebuilds it on the new design (Address → Send → Confirm → Sending, with a Select source sheet) with Android parity for MO-1121 (dash-wallet#1680).

Last app part of the stack; summary, acceptance criteria and known limits: docs/features/external-send/README.md.

What was done?

  • New ExternalSend module (DashWallet/Sources/UI/Payments/ExternalSend/): a SwiftUI screen + ViewModel per step, one flow, one executor over the existing spend seams (WalletSendService, SwiftDashSDKTransactionSender, the Platform/Shielded coordinators, the identity top-up and credit paths). No new way of spending money. ADR-0037
  • Four sources × four destination types decided by one pure policy (SendPairPolicy); unavailable pairs stay in Select source with their reason. ADR-0038
  • Fee estimated on Send, bound on Confirm: Continue authenticates and prepares, Confirm shows the prepared fee and only broadcasts. ADR-0039
  • Three outcomes (sent / not sent with Retry / in progress with no Retry), plus "moved to Platform" for a Shielded → Identity top-up that fails after the unshield. ADR-0040, ADR-0042
  • Routes that need the open dashpay/platform PRs (Identity → someone else's Shielded address, Platform → someone else's Identity ID, Shielded spends bound to an SDK plan) are unavailable or estimated here and come with feat(wallet): send from every balance to every destination type in the new Send flow #1358 after the pin bump.
  • Max on every route; on Identity it keeps the DashPay reserve.
  • BIP70 payment requests go through the existing BIP70 send; a failure after the merchant's ACK is reported as in progress, never Retry.
  • Screens and wiring (this PR): Address, Select source, Send, Confirm, Sending and the outcome sheets, the flow, previews per state; the services and domain from feat(wallet): domain model for sending to any destination #1406–fix(explore-dash): report a DashSpend payment the merchant acknowledged before it failed as in progress #1408.
  • Entry points: the Send menu, Scan Dash QR, the address field's scanner, a balance row's Send (pinned source), and a dash: link from another app. A link's sender is called back only when another app opened it (ADR-0007).
  • The old Send screen stays: send to a username and the older Payments screens still use it. Removing it is a follow-up.

Acceptance criteria → where they are covered

AC Code Tests
AC-01, AC-01b SendAmountViewModel, ConfirmViewModel, ExternalSendFeeEstimator SendAmountViewModelTests, ConfirmViewModelTests, ExternalSendFeeEstimatorTests
AC-02, AC-04, AC-15 DestinationParser, AddressViewModel, ExternalSendFlow DestinationParserTests, AddressViewModelTests, ExternalSendFlowTests
AC-03 AddressViewModel (clipboard read only on tap) AddressViewModelTests
AC-05, AC-06, AC-07, AC-10, AC-14 SendPairPolicy, SelectSourceViewModel SendPairPolicyTests, SelectSourceViewModelTests
AC-08, AC-09, AC-11 AmountRules, SendAmountViewModel AmountRulesTests, SendAmountViewModelTests
AC-12, AC-12b, AC-13, AC-13b IdentityLookupService, AddressViewModel, ConfirmViewModel IdentityLookupServiceTests, AddressViewModelTests, ConfirmViewModelTests
AC-16, AC-17, AC-18 SendPairPolicy warnings, ConfirmViewModel SendPairPolicyTests, ConfirmViewModelTests
AC-19 ExternalSendExecutor, SendOutcome, SendOutcomeRouter ExternalSendExecutorTests, SendOutcomeMappingTests, SendOutcomeRouterTests
AC-20 SendMenuRow SendMenuTests

How Has This Been Tested?

dashwallet-dashpay, Debug, iPhone 17 simulator (iOS 26.5): 2866 tests, 0 failures, 1 skipped on the whole stack. SwiftLint clean on the changed lines; scripts/a11y_audit.py --check reports no new findings.

  • Unit/component tests for every screen's ViewModel, the parser, the pair policy, the fee estimator, the flow, the outcome mapping and the executor over fakes
  • The Live adapters up to the SDK edge (destination decoding, credit overflow, the withdrawal minimum, how refusals are reported); the BIP70 send over a scripted wallet and transport
  • Maestro flows for the new screens (Send menu, Address incl. clipboard and scan, Select source with an unavailable pair, Max, the Identity row hidden without a username) — being added to the regression suite against this PR's build
  • A funded testnet send on each route (build, sign, broadcast and the Platform steps are not reachable from the unit-test host)
  • Identity → someone else's Core or Platform address end to end on testnet
  • Timing on the oldest supported iPhone: destination type after paste/scan ≤ 300 ms (p95), fee and total on Confirm ≤ 3 s (p95)

Breaking Changes

None. No schema change, no migration, no new setting; .platform-ref is unchanged.

Known limit: Core → someone else's Platform address whose recipient record is lost after the Core payment is not resumed (recovery refuses rather than paying the sender); the SDK fix is tracked in dashpay/platform#5824.

Stack

This replaces the single PR #1358 (+21k lines), split by layer so each part can be reviewed and merged on its own. Merge in order:

# PR What
0 #1405 chore(l10n): drop unused keys and sort the catalogs as BartyCrouch writes them (keeps the diffs below clean)
1 #1406 Domain: destinations, the parser, the pair policy, amount rules, send outcomes — pure logic, no UI
2 #1407 Services: the send executor over the existing spend seams, fee estimates, identity lookup, asset-lock recovery, BIP70 checks
3 #1408 DashSpend: a payment the merchant acknowledged before it failed is shown as in progress
4 #1409 The new Send screens and entry points
5 #1358 Routes that need the open dashpay/platform PRs (#5860, #5863, #5865) and the pin bump

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a guided external-send flow for entering or scanning a destination, choosing a source, setting an amount, reviewing fees and warnings, and confirming payment.
    • Added support for payment links and identity destinations, with clearer progress, validation, and failure messages.
    • Added retry options for eligible failed payments and updated send entry points to use the new flow.
  • Bug Fixes
    • Improved handling of clipboard suggestions, scanned payment details, and payment-request amounts during send setup.
  • Documentation
    • Added an overview of the external-send flow and its supported payment routes.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Walkthrough

This pull request adds an external-send flow for address entry, source selection, amount entry, confirmation, and send outcomes. Payment links and scans route through the new host. The Payments landing and internal-transfer UI remove the previous pinned-send-sheet path.

Changes: External send flow

Layer / File(s) Summary
Payment entry and orchestration
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift, ExternalSendFlow.swift, ExternalSendFlowScreen.swift, DWBasePayViewController.m, DWParsedPaymentURI.swift, DWQRScanModel.m, MainTabbarController.swift
Scanned inputs and payment URLs route to the external-send host. The flow resolves payment requests, manages stage transitions, and reports completion outcomes.
Address, source, and amount stages
DashWallet/Sources/UI/Payments/ExternalSend/Address/*, SelectSource/*, Send/*
The address stage handles parsing, clipboard input, and Identity lookup. Source selection applies pair policy. Amount entry handles balances, fees, Max planning, and amount validation.
Confirmation and outcomes
DashWallet/Sources/UI/Payments/ExternalSend/Confirm/*, Sending/*, Services/ExternalSendExecutor.swift
Confirmation prepares and sends the transaction, displays amounts and warnings, and handles cancellation. Outcome routing selects transaction details, toasts, or failure content with retry.
Payments landing and send menu
DashWallet/Sources/UI/Payments/Landing/*, DashWallet/Sources/UI/Payments/InternalTransfer/*
The landing routes address sends to the external-send host and no longer embeds a send form. The internal-transfer UI removes its pinned-send variant. The send card uses a shared menu-row model.
Validation and supporting updates
DashWalletTests/ExternalSend/*, DashWallet.xcodeproj/project.pbxproj, DashWallet/*.lproj/Localizable.strings, docs/features/external-send/README.md
Tests cover address, source, amount, confirmation, menu, and outcome behavior. Project configuration registers the new files. Localization resources and feature documentation add external-send content.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PaymentEntry
  participant ExternalSendHostController
  participant ExternalSendFlow
  participant PaymentRequestService
  participant ExternalSendExecutor
  PaymentEntry->>ExternalSendHostController: Open scanned payment or link
  ExternalSendHostController->>ExternalSendFlow: Resolve destination
  ExternalSendFlow->>PaymentRequestService: Fetch request when required
  PaymentRequestService-->>ExternalSendFlow: Return request details
  ExternalSendFlow->>ExternalSendExecutor: Prepare send
  ExternalSendExecutor-->>ExternalSendFlow: Return prepared send
  ExternalSendFlow->>ExternalSendExecutor: Send after confirmation
  ExternalSendFlow-->>ExternalSendHostController: Report outcome
Loading

Suggested reviewers: jeanpierreroma, quantumexplorer, thepastaclaw

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(wallet): new Send screens and entry points" matches the main change. The PR adds a new external-payment Send flow with Address, Select source, Send, Confirm, Sending and outcome screen…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(wallet): new Send screens and entry points" matches the main change. The PR adds a new external-payment Send flow with Address, Select source, Send, Confirm, Sending and outcome screens, plus new entry points from the Send menu, QR scanning and dash: links. The title is short and specific, and it does not describe anything absent from the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Review coverage is incomplete: 1 file could not be fully reviewed. Findings from completed review steps are included; see review info for details.

@thepastaclaw

thepastaclaw commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

♻️ No change to this PR's diff since commit 8444f06 (an empty commit, a merge of the base or a rebase onto it): that review stands — approved; @thepastaclaw review asks for a review of this commit (commit 6bf692e)

@romchornyi
romchornyi force-pushed the feat/external-send-screens branch from 8d78f63 to 6e4dfdc Compare November 13, 2026 13:40
@romchornyi romchornyi changed the title feat(external-send): new Send screens and entry points feat(wallet): new Send screens and entry points Nov 13, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The PR introduces two blocking defects in the new external-send flow: outcome toasts can be presented on a host that has already been popped, and multi-output BIP70 requests are confirmed with only their first recipient visible. Three additional state and acceptance-contract issues should be addressed before merge. The current simulator and accessibility checks are still queued; no completed code check on this head reports a change-caused failure.

🔴 2 blocking | 🟡 3 suggestion(s)

5 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Present send outcome toasts on the controller that remains visible
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:165-174

For the send-menu entry point, the host is pushed onto the Payments navigation stack and has no presenting controller. dismissAll captures root as self, pops the host at lines 170-172, and then invokes the completion with that same popped controller at line 173. The in-progress toast path and successful .sentToast path therefore call presentDashUIKitToast on an off-screen controller, so those outcomes can complete without displaying any toast. Capture the visible controller before popping, or deliver the completion after dismissal/pop using the controller that remains on the stack.

source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)

🔴 Blocking: Show every recipient in payment-request confirmation
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:272-276

requestDestination reduces the verified BIP70 confirmation to details.address, which is only Confirmation.primaryAddress, while amountDuffs is the aggregate amount of all resolved outputs. The BIP70 send later passes every confirmation.recipients entry to the transaction builder, so Confirm can display one legitimate recipient and the total while silently sending part of the payment to additional recipients. This is reachable for both unsigned requests, which are allowed by default, and signed merchant requests. Carry the resolved output list into the external-send destination/confirmation and render each recipient and amount, or reject multi-output requests before Confirm.

source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)

🟡 Suggestion: Display each source balance in Select source
DashWallet/Sources/UI/Payments/ExternalSend/SelectSource/SelectSourceViewModel.swift:45-58

The feature documentation explicitly defines AC-05 as listing every source with its balance, but Row contains only the source, title, availability reason, and selection state. SelectSourceSheet consequently renders only an icon, name, and availability/selection indicator, and this ViewModel never reads source balances. The test testRowsCarryNoBalanceForDisplay enforces the opposite of the documented acceptance criterion. Add a balance value to each row and render it, or update the acceptance contract and test to document the intentional icon-and-name-only design.

source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)

🟡 Suggestion: Expose and cancel the payment-request refetch state
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:203-211

retryFromSendFailed sets the private isRefetchingRequest flag and starts an asynchronous refetch, but that state is neither published nor passed to SendFailedSheet. Retry remains enabled without a loading indication, so a slow request looks unresponsive and repeated taps silently do nothing. Closing the sheet while the task is running also leaves the task able to call openSend after the flow has been dismissed, replacing ViewModels in an off-screen flow. Publish the loading state to disable/show progress on Retry and invalidate or cancel the refetch when the flow closes.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

🟡 Suggestion: Make Send loading idempotent across view reappearance
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountStepScreen.swift:47-51

The screen calls viewModel.load() from an unkeyed .task, while load() always re-reads the starting source and, for linked amounts, rewrites amountDuffs and amountText. If SwiftUI removes and re-inserts the Send screen during navigation or lifecycle changes, a second load can overwrite an amount the user typed or a source they selected. Guard initialization so it runs once per ViewModel, or make subsequent loads refresh only independent balance/fee state without resetting user input.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that directly alters funds movement across multiple wallet sources and payment execution paths, including ExternalSendExecutor, SendAmountViewModel, ConfirmViewModel, and the Platform/Shielded/identity send seams.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:165-174: Present send outcome toasts on the controller that remains visible
  For the send-menu entry point, the host is pushed onto the Payments navigation stack and has no presenting controller. `dismissAll` captures `root` as `self`, pops the host at lines 170-172, and then invokes the completion with that same popped controller at line 173. The in-progress toast path and successful `.sentToast` path therefore call `presentDashUIKitToast` on an off-screen controller, so those outcomes can complete without displaying any toast. Capture the visible controller before popping, or deliver the completion after dismissal/pop using the controller that remains on the stack.

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:272-276: Show every recipient in payment-request confirmation
  `requestDestination` reduces the verified BIP70 confirmation to `details.address`, which is only `Confirmation.primaryAddress`, while `amountDuffs` is the aggregate amount of all resolved outputs. The BIP70 send later passes every `confirmation.recipients` entry to the transaction builder, so Confirm can display one legitimate recipient and the total while silently sending part of the payment to additional recipients. This is reachable for both unsigned requests, which are allowed by default, and signed merchant requests. Carry the resolved output list into the external-send destination/confirmation and render each recipient and amount, or reject multi-output requests before Confirm.
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:203-211: Expose and cancel the payment-request refetch state
  `retryFromSendFailed` sets the private `isRefetchingRequest` flag and starts an asynchronous refetch, but that state is neither published nor passed to `SendFailedSheet`. Retry remains enabled without a loading indication, so a slow request looks unresponsive and repeated taps silently do nothing. Closing the sheet while the task is running also leaves the task able to call `openSend` after the flow has been dismissed, replacing ViewModels in an off-screen flow. Publish the loading state to disable/show progress on Retry and invalidate or cancel the refetch when the flow closes.

In `DashWallet/Sources/UI/Payments/ExternalSend/SelectSource/SelectSourceViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/SelectSource/SelectSourceViewModel.swift:45-58: Display each source balance in Select source
  The feature documentation explicitly defines AC-05 as listing every source with its balance, but `Row` contains only the source, title, availability reason, and selection state. `SelectSourceSheet` consequently renders only an icon, name, and availability/selection indicator, and this ViewModel never reads source balances. The test `testRowsCarryNoBalanceForDisplay` enforces the opposite of the documented acceptance criterion. Add a balance value to each row and render it, or update the acceptance contract and test to document the intentional icon-and-name-only design.

In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountStepScreen.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountStepScreen.swift:47-51: Make Send loading idempotent across view reappearance
  The screen calls `viewModel.load()` from an unkeyed `.task`, while `load()` always re-reads the starting source and, for linked amounts, rewrites `amountDuffs` and `amountText`. If SwiftUI removes and re-inserts the Send screen during navigation or lifecycle changes, a second load can overwrite an amount the user typed or a source they selected. Guard initialization so it runs once per ViewModel, or make subsequent loads refresh only independent balance/fee state without resetting user input.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Move identity lookup off the main actor in the SDK — The new Address flow awaits IdentityLookupService, whose live reader calls SDK.identityGet and dpnsGetUsername; both current SwiftDashSDK methods are @MainActor wrappers around synchronous FFI calls. An identity lookup can therefore freeze the Address UI for the full network request and timeout. The ownership and fix are already documented in proposed ADR-0045, which assigns the non-blocking operation to the platform/SDK binding rather than an app-side workaround.
    • Follow-up: Carry ADR-0045 in a dashpay/platform binding PR, expose genuinely non-main-actor identity and username reads, and pin-bump the app to that SDK change before relying on the identity-check flow in production.

@romchornyi

romchornyi commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Answers to the review of 6e4dfdce8 (findings not shown inline). Fixes are in 21e73ce.

  • Present send outcome toasts on the controller that remains visible — fixed: when the host was pushed on a navigation stack that stays (the Payments tab), the outcome toast is presented on that stack, not on the popped host. UIKit presentation, so no unit test; it goes into the Maestro flows for this feature.
  • Show every recipient in payment-request confirmation — deferred to Payment requests: follow-ups from the external-send review #1416: the existing Confirm shows the same primary recipient with the request's total (spec: payment-request fields behave as in the current Send); the decision (a "+N more recipients" line or refusing multi-output requests) is for both screens.
  • Display each source balance in Select source — not changing the screen: the design shows icon and name only, no balances. The public summary said otherwise and is corrected.
  • Expose and cancel the payment-request refetch state — fixed: Retry shows that it is refetching and is disabled meanwhile, and closing the flow cancels the refetch so nothing opens afterwards (testARetryFetchIsReportedAndClosingDuringItOpensNothing).
  • Make Send loading idempotent across view reappearance — fixed: the amount step loads once, so a picked source and a typed amount survive a reappearance (testASecondLoadKeepsThePickedSourceAndTheTypedAmount).

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Static review of the exact head confirms one blocking QR payment-request regression and six additional lifecycle, state, performance, error-reporting, and input-bounding issues in the new external-send flow. The simulator tests, target-membership, accessibility, workflow-lint, and recovery checks passed; the review check itself was still in progress.

🔴 1 blocking | 🟡 4 suggestion(s)

5 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Preserve the scanner's request-cleared fallback
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:226-227

The scanner's BIP70 failure path attaches a ParsedPaymentURI created by uriByClearingRequestURL, preserving the embedded Core address while removing rURL. Both scanner entry points discard that projection and forward only rawString; ExternalSendFlow.scannedDestination reparses the original URI, sees the original r=, and starts another payment-request fetch. A QR code with a valid fallback address therefore does not reliably open the editable address send after the first fetch fails, and a changed merchant response can replace the already-decided fallback. Pass the cleared parsed destination into the flow, or otherwise preserve an explicit no-request fallback when launching from DWPaymentInput.

source: gpt-6.1-sol (phase2-reviewer: general)

🟡 Suggestion: Cancel the initial payment-request fetch when leaving Address
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:229-232

resolved starts an unstructured task for the initial open operation, but only Retry's task is retained and cancellable. If the user backs out or closes Address while the initial request is awaiting the network, the request still completes and calls openSend after the flow has finished, resurrecting hidden send state and retaining the flow until the request returns. Retain and cancel the initial task, and guard its completion against a closed or superseded flow.

source: gpt-6.1-sol (phase2-reviewer: general)

🟡 Suggestion: Honor funding refusal when Max is selected
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:430-431

runEstimate records fundingRefusedAmount when canFund returns .notFundable, and isAffordable already incorporates that flag. However, state returns .ready for every Max amount before reaching that affordability check. If funding candidates change between Max planning and the funding check, Max remains enabled and reaches Confirm even though preparation cannot fund the route, causing unnecessary authentication before the user receives a failure. Max must be treated as not enough when fundingRefusedAmount is true, with a regression test for that transition.

if isMax { return fundingRefusedAmount ? .notEnough : .ready }

source: gpt-6.1-sol (phase2-reviewer: general)

🟡 Suggestion: Keep Core broadcast off the MainActor across the Swift/Rust boundary
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:358-361

Although this method starts transaction.broadcast() in a detached task, the live PreparedStandardSend broadcast closure calls SwiftDashSDKTransactionSender.broadcast. That adapter synchronously dispatches back to MainActor before invoking the Core SDK broadcast, whose Rust FFI implementation blocks while waiting for the network. The detached wrapper therefore still freezes MainActor during the broadcast. The blocking C-ABI call must execute on a worker, with only the authoritative outcome marshalled back to MainActor while preserving the finalized transaction's single-owner lifetime.

source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)

🟡 Suggestion: Preserve SDK/FFI preparation errors instead of reporting every failure as a fee failure
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:369-377

preparationError maps every error outside WalletSendService.errorDomain, and every unrecognized code inside that domain, to .feeUnavailable. The preparation path can instead fail with SDK/FFI conditions such as an invalid wallet handle, stale reservation, invalid parameter, or other transaction-building failure. The Confirm flow then shows a misleading fee error and loses the distinction needed for balance-race, wallet-lifecycle, or invalid-transaction handling. Preserve the underlying typed failure or add explicit mappings for the SDK and PlatformWallet error categories.

source: gpt-6.1-sol (phase2-reviewer: ffi-engineer)

Follow-up candidates (optional) (2)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Run identity lookup FFI off the MainActor
DashWallet/Sources/UI/Payments/ExternalSend/Address/AddressViewModel.swift:198-200

AddressViewModel is MainActor-isolated and awaits identityLookup.lookup here. The live adapter then obtains the SDK on MainActor and calls SDK.identityGet and SDK.dpnsGetUsername, whose implementations synchronously invoke the Rust FFI functions while remaining MainActor-isolated. Those FFI calls use a blocking runtime wait for DAPI, so continuing with an Identity ID can block the UI thread for the request or timeout. Move the blocking SDK/FFI work to an SDK-owned worker or nonisolated async boundary and deliver copied results back to MainActor.

source: gpt-6.1-sol (phase2-reviewer: ffi-engineer)

🟡 Suggestion: Bound clipboard input before splitting attacker-controlled text
DashWallet/Sources/UI/Payments/ExternalSend/Address/AddressViewModel.swift:104-106

An installed application can place an arbitrarily large string in the shared pasteboard. showClipboard passes the entire value to DestinationParser.find, which first creates a complete components(separatedBy:) array before the parser's destination-length checks run. A sufficiently large or whitespace-heavy clipboard payload can allocate excessive memory and execute on the MainActor, making the wallet unresponsive or terminating it. Reject or cap the clipboard payload before parsing.

guard let clipboardText = pasteboard.readString(),
      clipboardText.utf8.count <= 16_384 else {
    state = .clipboardNone
    return
}
let found = DestinationParser.find(in: clipboardText, network: network)

source: gpt-6.1-sol (phase2-reviewer: security-auditor)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that directly modifies funds movement and transaction preparation, signing, fee estimation, authentication, and broadcasting across ExternalSendExecutor, SendAmountViewModel, ConfirmViewModel, and the existing WalletSendService/SwiftDashSDKTransactionSender seams.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Code unchanged since the last final review (6e4dfdce): 2 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:226-227: Preserve the scanner's request-cleared fallback
  The scanner's BIP70 failure path attaches a `ParsedPaymentURI` created by `uriByClearingRequestURL`, preserving the embedded Core address while removing `rURL`. Both scanner entry points discard that projection and forward only `rawString`; `ExternalSendFlow.scannedDestination` reparses the original URI, sees the original `r=`, and starts another payment-request fetch. A QR code with a valid fallback address therefore does not reliably open the editable address send after the first fetch fails, and a changed merchant response can replace the already-decided fallback. Pass the cleared parsed destination into the flow, or otherwise preserve an explicit no-request fallback when launching from `DWPaymentInput`.

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:229-232: Cancel the initial payment-request fetch when leaving Address
  `resolved` starts an unstructured task for the initial `open` operation, but only Retry's task is retained and cancellable. If the user backs out or closes Address while the initial request is awaiting the network, the request still completes and calls `openSend` after the flow has finished, resurrecting hidden send state and retaining the flow until the request returns. Retain and cancel the initial task, and guard its completion against a closed or superseded flow.

In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:430-431: Honor funding refusal when Max is selected
  `runEstimate` records `fundingRefusedAmount` when `canFund` returns `.notFundable`, and `isAffordable` already incorporates that flag. However, `state` returns `.ready` for every Max amount before reaching that affordability check. If funding candidates change between Max planning and the funding check, Max remains enabled and reaches Confirm even though preparation cannot fund the route, causing unnecessary authentication before the user receives a failure. Max must be treated as not enough when `fundingRefusedAmount` is true, with a regression test for that transition.

In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:358-361: Keep Core broadcast off the MainActor across the Swift/Rust boundary
  Although this method starts `transaction.broadcast()` in a detached task, the live `PreparedStandardSend` broadcast closure calls `SwiftDashSDKTransactionSender.broadcast`. That adapter synchronously dispatches back to MainActor before invoking the Core SDK broadcast, whose Rust FFI implementation blocks while waiting for the network. The detached wrapper therefore still freezes MainActor during the broadcast. The blocking C-ABI call must execute on a worker, with only the authoritative outcome marshalled back to MainActor while preserving the finalized transaction's single-owner lifetime.
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:369-377: Preserve SDK/FFI preparation errors instead of reporting every failure as a fee failure
  `preparationError` maps every error outside `WalletSendService.errorDomain`, and every unrecognized code inside that domain, to `.feeUnavailable`. The preparation path can instead fail with SDK/FFI conditions such as an invalid wallet handle, stale reservation, invalid parameter, or other transaction-building failure. The Confirm flow then shows a misleading fee error and loses the distinction needed for balance-race, wallet-lifecycle, or invalid-transaction handling. Preserve the underlying typed failure or add explicit mappings for the SDK and PlatformWallet error categories.

@romchornyi
romchornyi force-pushed the feat/external-send-screens branch from 21e73ce to 6cdf15c Compare November 13, 2026 19:06
@romchornyi

romchornyi commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Answers to the re-review at 21e73ce (findings not shown inline); fixes are in 6cdf15c.

  • Preserve the scanner's request-cleared fallback (ExternalSendHostController.swift:226) — Not changing this: when the flow's fetch of the r= request fails again, ExternalSendFlow.open drops the request URL and opens Send for the link's own address, so the fallback is kept; the cost is one more fetch. If the merchant answers the second time, the verified request is paid, which is the intended outcome.
  • Cancel the initial payment-request fetch when leaving Address (ExternalSendFlow.swift:229) — Fixed: the fetch is retained as openTask, cancelled on a new resolve, on Back from Address and when the flow finishes; a cancelled fetch opens nothing. Test: testLeavingAddressWhileTheRequestIsFetchedOpensNothingWhenItReturns.
  • Honor funding refusal when Max is selected (SendAmountViewModel.swift:430) — Fixed as suggested: a Max the funding step refuses is not enough. Test: testAMaxTheFundingStepCannotPayIsNotEnoughAndContinueIsDisabled.
  • Keep Core broadcast off the MainActor (ExternalSendExecutor.swift:358) — Deferred: the main-actor hop is in SwiftDashSDKTransactionSender.broadcast, which predates this PR and serves every Core send (WalletSendService, masternode unban); tracked in Core broadcast blocks the main thread: SwiftDashSDKTransactionSender.broadcast hops to the main actor around the synchronous SDK call #1418.
  • Preserve SDK/FFI preparation errors (ExternalSendExecutor.swift:369) — Deferred to Payment requests: follow-ups from the external-send review #1416, together with the expired-request mapping it already tracks.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The reviewed head addresses the previously identified lifecycle, loading, and Max-funding issues, and no CodeRabbit findings are present. One scanner payment-request handoff still discards the scanner's cleared-request fallback and can refetch the original URL with different payment details; the simulator test check remains in progress, with no failed code checks in the supplied CI snapshot.

🔴 1 blocking

1 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Preserve the scanner's request-cleared fallback
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:226-227

DWQRScanModel attaches the request-cleared ParsedPaymentURI after its initial payment-request fetch fails, but byClearingRequestURL() retains the original rawString containing r=. This entry point forwards only that raw string and has no prefetched request after the failed scan fetch, so ExternalSendFlow reconstructs the request destination and fetches the original URL again. If the second response succeeds or differs, it replaces the scanner-established embedded address or amount instead of preserving the fallback; eventual fallback on a second failure does not make the behavior equivalent. Carry the cleared destination/request state through this entry point, or make the fallback decision explicit before opening the new flow.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change that directly modifies funds-movement paths and transaction preparation, signing, fee estimation, broadcasting, identity credits, and external-send execution in files such as ExternalSendExecutor.swift, ConfirmViewModel.swift, SendAmountViewModel.swift, and ExternalSendFlow.swift.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:226-227: Preserve the scanner's request-cleared fallback
  `DWQRScanModel` attaches the request-cleared `ParsedPaymentURI` after its initial payment-request fetch fails, but `byClearingRequestURL()` retains the original `rawString` containing `r=`. This entry point forwards only that raw string and has no prefetched request after the failed scan fetch, so `ExternalSendFlow` reconstructs the request destination and fetches the original URL again. If the second response succeeds or differs, it replaces the scanner-established embedded address or amount instead of preserving the fallback; eventual fallback on a second failure does not make the behavior equivalent. Carry the cleared destination/request state through this entry point, or make the fallback decision explicit before opening the new flow.

@romchornyi
romchornyi force-pushed the feat/external-send-screens branch from 6cdf15c to 9b77403 Compare November 13, 2026 21:07
@romchornyi

Copy link
Copy Markdown
Contributor Author

Re-review at 6cdf15c, fixed in 9b77403: scanner's request-cleared fallback — the launcher and the host's scanner delegate now pass requestCleared (the scanner attached the code with its r= cleared after its own fetch failed) into ExternalSendFlow, which opens the code's Core address with its amount, label and message and does not fetch the request again; a code with only a request is invalid once cleared. Covered in ExternalSendFlowTests.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The exact head still contains two lifecycle defects in the new external-send flow: payment-request Retry replaces the Send ViewModel without reloading the visible screen, and an Identity lookup can complete after Address has been exited and advance the dismissed flow. The simulator test check is still in progress; completed workflow, target-membership, recovery, accessibility, and CodeRabbit checks are successful.

🔴 1 blocking | 🟡 1 suggestion(s)

2 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Load the replacement Send model after payment-request Retry
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountStepScreen.swift:50

Payment-request Retry creates a new SendAmountViewModel in ExternalSendFlow.refetchRequest and assigns it to flow.sendViewModel while the existing .send navigation page remains visible. Because this screen uses an unkeyed .task, replacing the observed object does not cause the task to run again, leaving the replacement model with its default amount, route, balance, and fee state. The visible Send screen therefore cannot continue after a successful retry. Key the task to the ViewModel instance so each replacement model loads exactly once while preserving the ViewModel's existing idempotence.

Raised on code unchanged since the last review, and confirmed by an independent pass: After a payment-request send fails and Retry successfully refetches the request, refetchRequest replaces flow.sendViewModel while the NavigationStack remains on the existing .send page. The unkeyed .task does not rerun for the replacement SendAmountViewModel, so it retains default empty amount, unset route, and missing balance/fee state; Continue cannot proceed.

.task(id: ObjectIdentifier(viewModel)) { await viewModel.load() }

source: gpt-6.1-sol (phase2-reviewer: general)

🟡 Suggestion: Cancel an in-flight Identity lookup when leaving Address
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:184-186

backFromAddress() cancels only openTask, but an Identity destination performs its lookup directly inside AddressViewModel.proceed() before invoking onResolved. If the lookup is suspended when Back or close is pressed, it can later call handOn, invoke the flow's resolved closure, and open Send after the flow has already reported .backToMenu or .closed. Track the lookup task and cancel it when Address is exited, or add a finished/generation guard that rejects late lookup results.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate diff that changes funds-movement behavior across ExternalSendExecutor, WalletSendService integrations, transaction preparation/signing/broadcasting, identity credits, platform and shielded paths, and retry/outcome handling.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Code unchanged since the last final review (6cdf15cc): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountStepScreen.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountStepScreen.swift:50: Load the replacement Send model after payment-request Retry
  Payment-request Retry creates a new `SendAmountViewModel` in `ExternalSendFlow.refetchRequest` and assigns it to `flow.sendViewModel` while the existing `.send` navigation page remains visible. Because this screen uses an unkeyed `.task`, replacing the observed object does not cause the task to run again, leaving the replacement model with its default amount, route, balance, and fee state. The visible Send screen therefore cannot continue after a successful retry. Key the task to the ViewModel instance so each replacement model loads exactly once while preserving the ViewModel's existing idempotence.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: After a payment-request send fails and Retry successfully refetches the request, `refetchRequest` replaces `flow.sendViewModel` while the NavigationStack remains on the existing `.send` page. The unkeyed `.task` does not rerun for the replacement `SendAmountViewModel`, so it retains default empty amount, unset route, and missing balance/fee state; Continue cannot proceed._

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:184-186: Cancel an in-flight Identity lookup when leaving Address
  `backFromAddress()` cancels only `openTask`, but an Identity destination performs its lookup directly inside `AddressViewModel.proceed()` before invoking `onResolved`. If the lookup is suspended when Back or close is pressed, it can later call `handOn`, invoke the flow's `resolved` closure, and open Send after the flow has already reported `.backToMenu` or `.closed`. Track the lookup task and cancel it when Address is exited, or add a finished/generation guard that rejects late lookup results.

@romchornyi
romchornyi force-pushed the feat/external-send-screens branch from 1ed4d8f to fc1c558 Compare November 23, 2026 15:38
@romchornyi

Copy link
Copy Markdown
Contributor Author

Round 8 is addressed in fc1c558, one fix per finding:

  • Platform transfer Max: Fixed: Max and preparation both read the paying account through one check, PlatformSendFundingChecking.fundingCheck(route:amountDuffs:feeDuffs:). Platform to Platform Max is sized from transferAccountCredits() in LiveSendMaxPlanner, and requireFundable uses the same check.
  • Identity Max and the reserve: Fixed: preparation refuses an Identity Max that would dip into the DashPay reserve (requireFits(…, isMax:) → balanceNotEnough), and Send plans Max again. A typed amount keeps warn-and-allow.
  • Refused Identity Max re-plan: Fixed: pickSource and confirmReportedNotEnough both re-plan through replanMax(), which estimates the Identity fee first. The re-plan runs only while the amount is still the Max being re-planned.
  • Transaction-details swipe: Fixed: the details are presented full screen. Every step entry in ExternalSendHostController (start, resolve, Send, Confirm, Back, Select Source, Retry, route) is refused once the flow has ended.
  • Refetch error on Retry: Fixed: the flow keeps the failed refetch as retryFailure, and the Send-failed sheet shows it. There is no UIKit alert over the sheet.
  • Immediate close after open: Fixed: the open task checks isEnded before it starts.
  • Max while Continue prepares: Fixed: Max is disabled, and setAmountText is ignored, while Continue prepares.
  • AC-16 for Identity to Core: Not changing the code: AC-16 was narrowed to Shielded and Platform on 2026-11-11. The README line is corrected in feat(wallet): domain model for sending to any destination #1406.

Our pre-push check found more in the same rules; these are fixed in fc1c558 too:

  • Balance re-reads: Try again, the end of the restore sync, and Max read the source balance again, and a Max amount is planned again from that read. A known zero balance shows not enough before a fee failure. A re-plan runs only while the amount is still the Max being re-planned.
  • Locale separator: the amount is typed, shown and parsed with the locale's decimal separator, and text with anything else is not an amount.
  • Locked app: every entry into Send from the lock screen (scan, link) opens only after the PIN, or biometrics when the holder enabled them (ExternalSendLauncher.open).
  • Required payment request: a req-r request that cannot be fetched or verified ends with the request error rather than paying the address.
  • Address after Back: a scan or link that opens Send also fills Address, and showing the clipboard keeps Continue for a valid typed address.
  • Tall sheets: Confirm, Send-failed and the held-lock sheet keep their header and buttons and scroll their body when it is too tall.

On the pattern note: this round keeps each fix local and closes the rule at every site named above. Redesigning the Max plan and the flow-owned dismissal (ADR-0063) stays in #1450 rather than in this PR.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Changes requested: 3 blockers

  • Send opened from the lock screen stays accessible after auto-lock — DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:235-240 (new; not shown inline, see below)
    Impact: When the wallet auto-locks with a lock-screen Send flow open, balances can remain visible and an already-prepared payment can remain confirmable after the authentication session ends.
  • An unreadable balance on Retry turns Identity Max into a typed amount — DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:804-808 (new; not shown inline, see below)
    Impact: A user retrying Identity Max after a temporary balance-read failure can pay with an old amount that dips into the DashPay reserve, even though they never chose to type an amount.
  • Return Identity Max to Send when it no longer preserves the reserve — DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmViewModel.swift:286-289 (carried)
    Impact: A user can confirm an Identity Max payment after a balance update shows that the payment will consume credits Max was supposed to leave for DashPay.

New on this head: This revision of the new Send flow refreshes balances for Max and Retry, aligns Platform transfer Max with the paying account, adds authentication for lock-screen entry, and updates payment-request recovery and sheet layout. The exact-head CI snapshot shows the title checks passing and review queued; no build, XCTest, or funded-send result is available for this head.

A pattern across this PR's review rounds

This is review round 11, and the PR has drawn 17 blocking findings so far. 11 of them share 2 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. No single owner for the Send lifetime (2 new in this round, 5 earlier finding(s))

ExternalSendFlow owns its internal steps, but the launcher decides whether Send may open from the presenting controller, and the host still decides when the visible screens are done. Rendering Retry errors in the sheet and making transaction details full-screen fixed two paths without tying the flow to the wallet session. At the lock boundary, Home can admit a link while the root is still locked, and relocking does not end Send or discard an unsent confirmation on the lock window.

Already tracked: #1450

In this round: Send opened from the lock screen stays accessible after auto-lock; A second payment link can contact its merchant before wallet unlock

2. A refresh can replace the user's send intent (2 new in this round, 5 earlier finding(s))

SendAmountViewModel keeps the displayed amount outside SourceFacts but stores its Max meaning inside that replaceable snapshot; SendAmountRequest passes the resulting amount and isMax flag to preparation. Sharing the Platform paying-account check and the Identity fee-before-plan sequence made the checks agree, but Retry can still retain the amount while dropping Max, and restore completion can refresh the Core placeholder instead of the pinned source. The reserve check in ExternalSendExecutor can only enforce Max if the request still says it is Max.

Already tracked: #1450

In this round: An unreadable balance on Retry turns Identity Max into a typed amount; Restore completion can discard the pinned source while Send loads

Suggested decision (redesign the component): Finish the remaining ADR-0063 ownership work in #1409 before merging, rather than leaving it to #1450. Give ExternalSend one owner for the payment attempt: the wallet session governs admission and invalidation, the flow owns recovery and dismissal on the visible screen, and Send carries the selected source and explicit Max intent through refresh and preparation under the same route rules. A failed read may make a Max plan unavailable; it must not turn it into a typed payment.

🔴 3 blocking | 🟡 5 suggestion(s)

8 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Send opened from the lock screen stays accessible after auto-lock
Impact: When the wallet auto-locks with a lock-screen Send flow open, balances can remain visible and an already-prepared payment can remain confirmable after the authentication session ends.
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:235-240

A lock-screen Send flow does not become inaccessible when its authenticated session expires. The new launcher authenticates entry but presents Send on the existing lock window, without completing the ordinary unlock transition. Backgrounding clears the session, but the root keeps the existing lock navigation controller and the Send presentation survives above it. Confirm still relies on preparation-time authorization and can dispatch without a fresh session check. Complete the normal unlock transition before presenting Send, or close the lock-owned flow and discard unsent preparation when the session expires. Verify both the amount screen and prepared Confirm across auto-lock; handle detailed reproduction privately under ADR-0001.

Confirmed by an independent pass: When the wallet holder opens Scan to Send from the lock screen and authenticates, Send is presented on the lock window without completing the normal unlock transition. If the app backgrounds long enough to auto-lock, that presentation still exposes wallet balances on return, and an already prepared payment can be broadcast without fresh authentication.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🔴 Blocking: An unreadable balance on Retry turns Identity Max into a typed amount
Impact: A user retrying Identity Max after a temporary balance-read failure can pay with an old amount that dips into the DashPay reserve, even though they never chose to type an amount.
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:804-808

Retry can silently remove the reserve protection from the amount already on screen. When Continue cannot read an Identity balance, Send offers Try again. The new Retry path starts a Max replan, but if the live balance is still unavailable, identityMaxDuffs() returns nil and planMax() clears facts.max without clearing amountDuffs. When the balance becomes readable on a later Retry, the model skips replanning; if the old amount and fee still fit but leave less than the reserve, Continue passes isMax: false and preparation permits it as a typed amount. Keep the Max intent in a retryable, non-confirmable state until a fresh plan succeeds or the user edits the amount. Cover an unavailable refresh followed by a lower readable balance.

Raised on code unchanged since the last review, and confirmed by an independent pass: A holder can choose Identity Max from the cached balance during startup, then get Try again if Core startup fails and temporarily takes down the wallet host. If the first retry still cannot read the balance, and the host later reopens with a lower balance saved by identity discovery, the next retry leaves the old amount on screen and lets Continue prepare it as a typed amount. The holder can therefore confirm a send that draws down the DashPay reserve even though they selected Max and never edited the amount.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🔴 Blocking: Return Identity Max to Send when it no longer preserves the reserve
Impact: A user can confirm an Identity Max payment after a balance update shows that the payment will consume credits Max was supposed to leave for DashPay.
DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmViewModel.swift:286-289

Confirm can enable an Identity Max that its own balance read shows will dip into the reserve. The new requireFits(..., isMax:) rejects this at preparation, but makeWarnings reads the balance again afterward. If a recent Identity debit is reflected in that newer snapshot and the payment plus fee still fits, .okWithReserveWarning only adds a caution and prepare() publishes .ready. Dispatch checks that the identity is still current, not that the reserve is intact, and LiveIdentityCreditsSend spends the prepared amount without using isMax. Reuse the Max affordability rule on the confirmation read and before dispatch: discard or refuse the send and return to Send for a new Max. Keep warn-and-allow for typed amounts only. Test a lower balance after successful preparation, not just a refusal during preparation.

source: gpt-6.2-astra (phase2-reviewer: general)

🟡 Suggestion: Do not prefetch BIP70 requests for non-Core destinations
Impact: Scanning an Identity payment link that the new Send flow rejects can still contact its merchant URL and make the user wait for the response.
DashWallet/Sources/UI/Payments/ScanQR/DWQRScanModel.m:198-203

The scanner can send a merchant request before rejecting the link, exposing the scan time and network address to the endpoint. The rebased DestinationParser rejects an Identity link carrying a payment-request field, so the whole-link isIdentityIDString: predicate returns false. isValidDashPaymentIntent still succeeds because rURL exists, and the bech32 routing flag is false for an Identity ID. The prefetch therefore runs before ScanInput can reject the link. Decide to fetch from a positively validated Core or request-only destination, preserving the separate whole-URL BIP73 case. Test the scanner’s fetch decision, not just ScanInput.

source: gpt-6.2-astra (phase2-reviewer: general)

🟡 Suggestion: A second payment link can contact its merchant before wallet unlock
Impact: If a warm, locked wallet already has a deferred link, a second Core payment link can start merchant verification before the user unlocks the wallet.
DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m:104-109

Merchant verification can start before unlock even though the lock window still covers Send. The root router returns only when the wallet is locked and the deferred slot is empty. A subsequent link reaches Home via MainTabbarController.performPay(to:), where requiresAuthenticationToSend returns NO. The new launcher starts the flow before presenting the host, so a Core-address link with a merchant request can start network I/O immediately; the previous Core-address deep-link path opened an amount screen first. This path does not itself authorize or broadcast a payment. Enforce deferral at the root regardless of whether its slot is occupied, and test two deliveries while locked.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Reject stale Max plans after the amount or source changes
Impact: A keypad edit already queued when Max starts can be replaced by the calculated maximum instead of remaining the user's latest amount.
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:520-525

A newer edit can still lose in the handoff between Max's new balance read and its planner. The pinned keypad disables new presses once it receives inProgress, but the binding dispatches an accepted press in a Task, and setAmountText still accepts that pending edit during the read. It clears Max and replaces the amount task, not the source task. When the read completes, tapMax calls replanMax() unconditionally and starts a fresh amount operation, so cancellation of the prior operation does not protect the edit. Carry an intent marker across the read and check that it is still current before planning. Hold the balance reader, rather than the planner, in the regression test.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Restore completion can discard the pinned source while Send loads
Impact: A user opening Send from an eligible Shielded or Platform balance row just as restore sync finishes can see Core selected without a source-change notice.
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:226-230

Send can replace the pinned source with its initial Core placeholder. didLoad becomes true before the initial identity and balance reads finish, while facts still has .core and no route. The new restore-completion refresh calls rereadSource() on that placeholder; readSource cancels the task that would have applied startingSource and its notice. Defer the refresh until source selection exists, or fold it into the pending initial selection. The current restore test sends the event after loading and picking a source; add one that holds an initial read and delivers the event before selection.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Tall Send sheets can clip content even at the end of scrolling
Impact: Users whose Confirm or Send failed sheet reaches its height cap can have content remain below the visible viewport even after scrolling to the end.
DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift:185-192

The ScrollView can reserve more height than the sheet actually displays below its header. At the pinned DashUIKit revision b295cb80, a titled sheet has an 18-point grabber and a navigation bar at least 74 points high. CappedSheetBody subtracts only 72 points from the same maximum, so its viewport can exceed the available body height by at least 20 points. Scrolling only moves content within that oversized viewport. Size the viewport from the actual space below the header, preferably in the DashUIKit component that owns the header and detent.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The diff adds intricate funds-movement orchestration in ConfirmViewModel.swift, which prepares an authenticated spend, binds it to the confirmation step, and invokes the executor to send it on explicit confirmation.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: models 0% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • New since the last final review (1ed4d8fb): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 2 confirmed
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): No single owner for the Send lifetime; A refresh can replace the user's send intent. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Finish the remaining ADR-0063 ownership work in #1409 before merging, rather than leaving it to #1450. Give ExternalSend one owner for the payment attempt: the wallet session governs admission and invalidation, the flow owns recovery and dismissal on the visible screen, and Send carries the selected source and explicit Max intent through refresh and preparation under the same route rules. A failed read may make a Max plan unavailable; it must not turn it into a typed payment. If that decision is not yours to make, say so to the PR's author or maintainer.

These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:235-240: Send opened from the lock screen stays accessible after auto-lock
  Impact: When the wallet auto-locks with a lock-screen Send flow open, balances can remain visible and an already-prepared payment can remain confirmable after the authentication session ends.
  A lock-screen Send flow does not become inaccessible when its authenticated session expires. The new launcher authenticates entry but presents Send on the existing lock window, without completing the ordinary unlock transition. Backgrounding clears the session, but the root keeps the existing lock navigation controller and the Send presentation survives above it. Confirm still relies on preparation-time authorization and can dispatch without a fresh session check. Complete the normal unlock transition before presenting Send, or close the lock-owned flow and discard unsent preparation when the session expires. Verify both the amount screen and prepared Confirm across auto-lock; handle detailed reproduction privately under ADR-0001.

  _Confirmed by an independent pass: When the wallet holder opens Scan to Send from the lock screen and authenticates, Send is presented on the lock window without completing the normal unlock transition. If the app backgrounds long enough to auto-lock, that presentation still exposes wallet balances on return, and an already prepared payment can be broadcast without fresh authentication._

In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:804-808: An unreadable balance on Retry turns Identity Max into a typed amount
  Impact: A user retrying Identity Max after a temporary balance-read failure can pay with an old amount that dips into the DashPay reserve, even though they never chose to type an amount.
  Retry can silently remove the reserve protection from the amount already on screen. When Continue cannot read an Identity balance, Send offers Try again. The new Retry path starts a Max replan, but if the live balance is still unavailable, `identityMaxDuffs()` returns nil and `planMax()` clears `facts.max` without clearing `amountDuffs`. When the balance becomes readable on a later Retry, the model skips replanning; if the old amount and fee still fit but leave less than the reserve, Continue passes `isMax: false` and preparation permits it as a typed amount. Keep the Max intent in a retryable, non-confirmable state until a fresh plan succeeds or the user edits the amount. Cover an unavailable refresh followed by a lower readable balance.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: A holder can choose Identity Max from the cached balance during startup, then get Try again if Core startup fails and temporarily takes down the wallet host. If the first retry still cannot read the balance, and the host later reopens with a lower balance saved by identity discovery, the next retry leaves the old amount on screen and lets Continue prepare it as a typed amount. The holder can therefore confirm a send that draws down the DashPay reserve even though they selected Max and never edited the amount._
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:520-525: Reject stale Max plans after the amount or source changes
  Impact: A keypad edit already queued when Max starts can be replaced by the calculated maximum instead of remaining the user's latest amount.
  A newer edit can still lose in the handoff between Max's new balance read and its planner. The pinned keypad disables new presses once it receives `inProgress`, but the binding dispatches an accepted press in a `Task`, and `setAmountText` still accepts that pending edit during the read. It clears Max and replaces the amount task, not the source task. When the read completes, `tapMax` calls `replanMax()` unconditionally and starts a fresh amount operation, so cancellation of the prior operation does not protect the edit. Carry an intent marker across the read and check that it is still current before planning. Hold the balance reader, rather than the planner, in the regression test.
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:226-230: Restore completion can discard the pinned source while Send loads
  Impact: A user opening Send from an eligible Shielded or Platform balance row just as restore sync finishes can see Core selected without a source-change notice.
  Send can replace the pinned source with its initial Core placeholder. `didLoad` becomes true before the initial identity and balance reads finish, while `facts` still has `.core` and no route. The new restore-completion refresh calls `rereadSource()` on that placeholder; `readSource` cancels the task that would have applied `startingSource` and its notice. Defer the refresh until source selection exists, or fold it into the pending initial selection. The current restore test sends the event after loading and picking a source; add one that holds an initial read and delivers the event before selection.

In `DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmViewModel.swift:286-289: Return Identity Max to Send when it no longer preserves the reserve
  Impact: A user can confirm an Identity Max payment after a balance update shows that the payment will consume credits Max was supposed to leave for DashPay.
  Confirm can enable an Identity Max that its own balance read shows will dip into the reserve. The new `requireFits(..., isMax:)` rejects this at preparation, but `makeWarnings` reads the balance again afterward. If a recent Identity debit is reflected in that newer snapshot and the payment plus fee still fits, `.okWithReserveWarning` only adds a caution and `prepare()` publishes `.ready`. Dispatch checks that the identity is still current, not that the reserve is intact, and `LiveIdentityCreditsSend` spends the prepared amount without using `isMax`. Reuse the Max affordability rule on the confirmation read and before dispatch: discard or refuse the send and return to Send for a new Max. Keep warn-and-allow for typed amounts only. Test a lower balance after successful preparation, not just a refusal during preparation.

In `DashWallet/Sources/UI/Payments/ScanQR/DWQRScanModel.m`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ScanQR/DWQRScanModel.m:198-203: Do not prefetch BIP70 requests for non-Core destinations
  Impact: Scanning an Identity payment link that the new Send flow rejects can still contact its merchant URL and make the user wait for the response.
  The scanner can send a merchant request before rejecting the link, exposing the scan time and network address to the endpoint. The rebased `DestinationParser` rejects an Identity link carrying a payment-request field, so the whole-link `isIdentityIDString:` predicate returns false. `isValidDashPaymentIntent` still succeeds because `rURL` exists, and the bech32 routing flag is false for an Identity ID. The prefetch therefore runs before `ScanInput` can reject the link. Decide to fetch from a positively validated Core or request-only destination, preserving the separate whole-URL BIP73 case. Test the scanner’s fetch decision, not just `ScanInput`.

In `DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m:104-109: A second payment link can contact its merchant before wallet unlock
  Impact: If a warm, locked wallet already has a deferred link, a second Core payment link can start merchant verification before the user unlocks the wallet.
  Merchant verification can start before unlock even though the lock window still covers Send. The root router returns only when the wallet is locked and the deferred slot is empty. A subsequent link reaches Home via `MainTabbarController.performPay(to:)`, where `requiresAuthenticationToSend` returns `NO`. The new launcher starts the flow before presenting the host, so a Core-address link with a merchant request can start network I/O immediately; the previous Core-address deep-link path opened an amount screen first. This path does not itself authorize or broadcast a payment. Enforce deferral at the root regardless of whether its slot is occupied, and test two deliveries while locked.

In `DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift:185-192: Tall Send sheets can clip content even at the end of scrolling
  Impact: Users whose Confirm or Send failed sheet reaches its height cap can have content remain below the visible viewport even after scrolling to the end.
  The ScrollView can reserve more height than the sheet actually displays below its header. At the pinned DashUIKit revision `b295cb80`, a titled sheet has an 18-point grabber and a navigation bar at least 74 points high. `CappedSheetBody` subtracts only 72 points from the same maximum, so its viewport can exceed the available body height by at least 20 points. Scrolling only moves content within that oversized viewport. Size the viewport from the actual space below the header, preferably in the DashUIKit component that owns the header and detent.

@romchornyi
romchornyi force-pushed the feat/external-send-screens branch from fc1c558 to f26fdf5 Compare November 24, 2026 09:23
@romchornyi

Copy link
Copy Markdown
Contributor Author

Review round 9, fixed in f26fdf5 (stack rebased on develop 43e07f371):

  • Send opened from the lock screen and auto-lock — Fixed: Send never opens above the lock screen. Every payment entry that arrives while the wallet is locked waits for the unlock. Applied at the lock screen's scanner (presentScannedPaymentInput: authenticates first, then hands the scan to the root, which opens Send over the unlocked app, so auto-lock covers it), the lock screen's scanner prefetch (defersPaymentRequests: the payment request is fetched by Send after the unlock), DWAppRootViewController.handleURL (a link always defers while locked; the newest link wins), and wipe (drops a deferred link or scan). External send: one lifecycle owner, a typed scan result and a source snapshot with unknown balances #1450 stays for the lifecycle owner.
  • Max with an unreadable Identity balance — Fixed: Max intent survives a failed re-plan as not confirmable (.unplanned → fee-failed) until a plan succeeds or the user edits the amount. Applied at retry, the source re-read and a second Max tap on an amount that already is Max.
  • Identity Max into the reserve at Confirm — Fixed: an Identity Max whose reserve check at Confirm is not .ok, or whose balance read failed, returns to Send; dispatch rechecks it (feat(wallet): send services, asset-lock recovery and payment-request checks #1407 ExternalSendExecutor.identityMaxRefusal). A typed amount keeps warn-and-allow.
  • Keypad edit during Max's balance read — Fixed: Max plans only if its intent is still current after the read.
  • Restore-sync refresh before the pinned source — Fixed: the refresh waits until the starting source is applied.
  • Scanner prefetch for a link the parser rejects — Fixed: the scanner prefetches only when DestinationParser keeps a payment-request URL (http(s) with a host); a BIP73 URL scanned whole still is.
  • Sheet viewport taller than the body — Fixed: CappedSheetBody subtracts the real header (18 + 74 pt). Applies to Confirm, Send-failed and feat(wallet): offer to finish a send whose asset lock is held #1423's held-lock sheet.

Tests: SendAmountViewModelTests (Max intent, edit during the read, restore-sync), ConfirmViewModelTests (reserve and unread balance), ExternalSendFlowTests (prefetch gate, unlock before Send).

Test notes, not covered by unit tests: the lock-screen scan → unlock → Send path with auto-lock, and the capped sheets at the largest text size, are to be checked on a device.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 2 only (queue backlog)

Changes requested: 2 blockers

  • Entering the visible PIN after a lock-screen scan can lose the scanned payment — DashWallet/Sources/UI/LockScreen/DWLockScreenViewController.m:362-369 (new; not shown inline, see below)
    Impact: A holder who scans after auto-lock with biometrics off can enter the correct PIN and see another prompt instead of the scanned destination.
  • The scanner prefetch test fails on a clean mainnet test host — DashWalletTests/ExternalSend/ExternalSendFlowTests.swift:598-600 (new; not shown inline, see below)
    Impact: A developer or CI runner on a clean host gets a failing positive assertion even though the scanner is correctly rejecting a wrong-network address.

New on this head: This rebase moves lock-screen scans onto the main app after unlock, tightens payment-request prefetch, and preserves Identity Max intent through balance refreshes while rechecking the reserve at confirmation and dispatch. Title validation and CodeRabbit passed, and the review check is pending; no build, XCTest, or device-smoke result was available for this head.

A pattern across this PR's review rounds

This is review round 12, and the PR has drawn 19 blocking findings so far. 2 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. No single owner for Send across wallet lock (3 new in this round, 2 earlier finding(s))

Moving Send off the lock window changed where it opens, but not who owns the handoff: a scan waits in the callback from ExternalSendLauncher.authenticateToUnlock, while DWAppRootViewController separately handles ordinary unlock and deferred links. The normal unlock can finish without handing off the scan, and replay can clear a link that handleURL just deferred again. ExternalSendFlow still ends with its host rather than with the wallet session, so the patch moved the problem from where Send was presented to how a payment gets through unlock.

Already tracked: #1450

In this round: Entering the visible PIN after a lock-screen scan can lose the scanned payment; A successful scan prompt does not prove the current wallet session is unlocked; Unlock can erase a payment link that the router just deferred again

Suggested decision (redesign the component): Finish the wallet-session part of ADR-0063 in #1409 rather than leaving it to #1450. Make the root's normal lock and unlock path own pending scans and links: it hands them to ExternalSendFlow only after the wallet has unlocked, keeps them pending if unlock has not completed, and invalidates unsubmitted Send attempts on relock. A separate payment prompt should not own the pending scan or decide that the wallet has unlocked.

🔴 2 blocking | 🟡 3 suggestion(s)

5 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Entering the visible PIN after a lock-screen scan can lose the scanned payment
Impact: A holder who scans after auto-lock with biometrics off can enter the correct PIN and see another prompt instead of the scanned destination.
DashWallet/Sources/UI/LockScreen/DWLockScreenViewController.m:362-369

The visible lock-screen keypad can unlock the wallet without delivering the scan. After the scanner dismisses, the new handoff starts a separate PIN prompt that owns the payment input. PinPromptPresenter checks the app delegate's window first and accepts an attached presenter even when that window is not key. After auto-lock, that window is still attached underneath the key lock window. The holder enters their PIN on the visible lock screen, which calls the ordinary unlock delegate without setting deferredScannedInput. Removing the lock window can then reveal the second prompt, whose completion only weakly references the old lock controller. Queue the scan for the existing unlock path, or explicitly present the prompt that owns the scan on the lock window. Verify that one PIN entry opens the scanned destination and cancellation opens nothing.

Confirmed by an independent pass: After the wallet auto-locks, a user with biometrics disabled can tap Scan to Send and scan a valid payment QR code. The scan starts a PIN prompt on the app window beneath the lock screen, so the user enters the correct PIN on the keypad they can see. That keypad unlocks the wallet without queuing the scan, so Send does not open with the scanned destination.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🔴 Blocking: The scanner prefetch test fails on a clean mainnet test host
Impact: A developer or CI runner on a clean host gets a failing positive assertion even though the scanner is correctly rejecting a wrong-network address.
DashWalletTests/ExternalSend/ExternalSendFlowTests.swift:598-600

The first XCTAssertTrue evaluates to false on the default test host. The new test builds coreAddress with .testnet, but it calls the live prefetchesPaymentRequest property directly, not the injected testnet harness. That property uses WalletEnvironment.networkKind; with no persisted selection it reads .mainnet, and DestinationParser rejects the address before retaining its request URL. Some negative assertions can pass for the same unrelated reason. Build the fixture for the network being validated, or expose a network-parameterized decision and assert both matching- and wrong-network behavior.

Confirmed by an independent pass: Running DashWalletTests on a clean Debug host leaves CURRENT_CHAIN_TYPE_KEY unset, so the live network is mainnet. The new scanner prefetch test passes a testnet Core address to that live code path; DestinationParser rejects the address, prefetchesPaymentRequest returns false, and the first XCTAssertTrue fails.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: A successful scan prompt does not prove the current wallet session is unlocked
Impact: The lock-screen handoff can expose the wallet UI or start a deferred payment request without authorization for the current foreground session.
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:247-267

This head gives a generic payment-gate success the authority to dismiss the wallet lock. The live gate does not distinguish verified credentials from a policy skip, and the best-effort legacy policy upgrade is not a guarantee that the skip branch is unreachable. I could not establish that a shipped iOS version produced the legacy state needed for that branch, so this is not a verified blocking bypass. Independently, a successful PIN result is delivered after the prompt's animated dismissal, while backgrounding clears the authenticated session. Neither the scan callback nor the root's post-animation scan dispatch revalidates the session or lock owner. Use the existing credential-verified unlock path for the queued scan, and consume it only while that unlock still owns the current foreground session. Test both a policy-skip result and a session invalidated before the handoff finishes.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Unlock can erase a payment link that the router just deferred again
Impact: If the router still considers the wallet locked during unlock completion, the holder loses the pending link instead of seeing it after the next unlock.
DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:500-503

A replay that needs to wait for another unlock is lost. The revised handleURL: always writes the URL to deferredURLToProcess and returns when the lock check is true. That check can still be true after the animation if the model requires a lock again or the old controller is still retained; clearing the lock window's root does not explicitly clear the controller used as the marker. The caller then clears deferredURLToProcess, erasing the retry. Retire the completed lock marker explicitly, and take and clear the URL before routing so a new deferral survives.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Tall Send sheets can clip content even at the end of scrolling
Impact: A holder in a constrained presentation can scroll a tall Confirm or Send-failed sheet to the end and still have its bottom controls partly out of view.
DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift:175-195

The revised subtraction accounts for the pinned DashUIKit grabber and minimum navigation-bar height, but the scroll viewport still uses 95% of the key window rather than the available sheet height. At the pinned revision, BottomSheet.selfSizing fixes the sheet at its ideal vertical size and requests a .height(...) detent. When the system offers less room, the fixed scroll frame can extend past the visible sheet; the scroll view stops at the bottom of its own frame, not at the bottom of the presentation. Size the scroll region from the space actually available below the header, and verify that the last action is reachable in a constrained presentation.

source: gpt-6.2-astra (phase2-reviewer: general)

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — Beyond the new screens, ConfirmViewModel.swift adds an intricate funds-movement control path that authenticates and prepares the payment, binds its details for review, and submits it on explicit confirmation.
  • Phase 1 reviewers: not run (skipped for throughput: 13 PRs queued, above the 10 limit)
  • New since the last final review (fc1c558a): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 2 confirmed
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): No single owner for Send across wallet lock. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Finish the wallet-session part of ADR-0063 in #1409 rather than leaving it to #1450. Make the root's normal lock and unlock path own pending scans and links: it hands them to `ExternalSendFlow` only after the wallet has unlocked, keeps them pending if unlock has not completed, and invalidates unsubmitted Send attempts on relock. A separate payment prompt should not own the pending scan or decide that the wallet has unlocked. If that decision is not yours to make, say so to the PR's author or maintainer.

These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/LockScreen/DWLockScreenViewController.m`:
- [BLOCKING] DashWallet/Sources/UI/LockScreen/DWLockScreenViewController.m:362-369: Entering the visible PIN after a lock-screen scan can lose the scanned payment
  Impact: A holder who scans after auto-lock with biometrics off can enter the correct PIN and see another prompt instead of the scanned destination.
  The visible lock-screen keypad can unlock the wallet without delivering the scan. After the scanner dismisses, the new handoff starts a separate PIN prompt that owns the payment input. `PinPromptPresenter` checks the app delegate's window first and accepts an attached presenter even when that window is not key. After auto-lock, that window is still attached underneath the key lock window. The holder enters their PIN on the visible lock screen, which calls the ordinary unlock delegate without setting `deferredScannedInput`. Removing the lock window can then reveal the second prompt, whose completion only weakly references the old lock controller. Queue the scan for the existing unlock path, or explicitly present the prompt that owns the scan on the lock window. Verify that one PIN entry opens the scanned destination and cancellation opens nothing.

  _Confirmed by an independent pass: After the wallet auto-locks, a user with biometrics disabled can tap Scan to Send and scan a valid payment QR code. The scan starts a PIN prompt on the app window beneath the lock screen, so the user enters the correct PIN on the keypad they can see. That keypad unlocks the wallet without queuing the scan, so Send does not open with the scanned destination._

In `DashWalletTests/ExternalSend/ExternalSendFlowTests.swift`:
- [BLOCKING] DashWalletTests/ExternalSend/ExternalSendFlowTests.swift:598-600: The scanner prefetch test fails on a clean mainnet test host
  Impact: A developer or CI runner on a clean host gets a failing positive assertion even though the scanner is correctly rejecting a wrong-network address.
  The first `XCTAssertTrue` evaluates to false on the default test host. The new test builds `coreAddress` with `.testnet`, but it calls the live `prefetchesPaymentRequest` property directly, not the injected testnet harness. That property uses `WalletEnvironment.networkKind`; with no persisted selection it reads `.mainnet`, and `DestinationParser` rejects the address before retaining its request URL. Some negative assertions can pass for the same unrelated reason. Build the fixture for the network being validated, or expose a network-parameterized decision and assert both matching- and wrong-network behavior.

  _Confirmed by an independent pass: Running DashWalletTests on a clean Debug host leaves CURRENT_CHAIN_TYPE_KEY unset, so the live network is mainnet. The new scanner prefetch test passes a testnet Core address to that live code path; DestinationParser rejects the address, prefetchesPaymentRequest returns false, and the first XCTAssertTrue fails._

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:247-267: A successful scan prompt does not prove the current wallet session is unlocked
  Impact: The lock-screen handoff can expose the wallet UI or start a deferred payment request without authorization for the current foreground session.
  This head gives a generic payment-gate success the authority to dismiss the wallet lock. The live gate does not distinguish verified credentials from a policy skip, and the best-effort legacy policy upgrade is not a guarantee that the skip branch is unreachable. I could not establish that a shipped iOS version produced the legacy state needed for that branch, so this is not a verified blocking bypass. Independently, a successful PIN result is delivered after the prompt's animated dismissal, while backgrounding clears the authenticated session. Neither the scan callback nor the root's post-animation scan dispatch revalidates the session or lock owner. Use the existing credential-verified unlock path for the queued scan, and consume it only while that unlock still owns the current foreground session. Test both a policy-skip result and a session invalidated before the handoff finishes.

In `DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m`:
- [SUGGESTION] DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:500-503: Unlock can erase a payment link that the router just deferred again
  Impact: If the router still considers the wallet locked during unlock completion, the holder loses the pending link instead of seeing it after the next unlock.
  A replay that needs to wait for another unlock is lost. The revised `handleURL:` always writes the URL to `deferredURLToProcess` and returns when the lock check is true. That check can still be true after the animation if the model requires a lock again or the old controller is still retained; clearing the lock window's root does not explicitly clear the controller used as the marker. The caller then clears `deferredURLToProcess`, erasing the retry. Retire the completed lock marker explicitly, and take and clear the URL before routing so a new deferral survives.

In `DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift:175-195: Tall Send sheets can clip content even at the end of scrolling
  Impact: A holder in a constrained presentation can scroll a tall Confirm or Send-failed sheet to the end and still have its bottom controls partly out of view.
  The revised subtraction accounts for the pinned DashUIKit grabber and minimum navigation-bar height, but the scroll viewport still uses 95% of the key window rather than the available sheet height. At the pinned revision, `BottomSheet.selfSizing` fixes the sheet at its ideal vertical size and requests a `.height(...)` detent. When the system offers less room, the fixed scroll frame can extend past the visible sheet; the scroll view stops at the bottom of its own frame, not at the bottom of the presentation. Size the scroll region from the space actually available below the header, and verify that the last action is reachable in a constrained presentation.

@romchornyi
romchornyi force-pushed the feat/external-send-screens branch from f26fdf5 to 1293a05 Compare November 24, 2026 18:56
@romchornyi

Copy link
Copy Markdown
Contributor Author

Rebased on develop 631100a03 (ADR-0054 → ADR-0066 renumbering in #1406, docs only, no code change): this PR f26fdf5 → 1293a05. The round 9 fixes are unchanged.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Changes requested: 2 blockers

  • Entering the visible PIN after a lock-screen scan can lose the scanned payment — DashWallet/Sources/UI/LockScreen/DWLockScreenViewController.m:362-369 (carried)
    Impact: With biometrics disabled, a holder who scans from the lock screen and enters the PIN on its visible keypad unlocks the app without opening the scanned payment.
  • The scanner prefetch test fails on a clean mainnet test host — DashWalletTests/ExternalSend/ExternalSendFlowTests.swift:598-600 (carried)
    Impact: A clean simulator host rejects the positive test fixture as a wrong-network address, failing the first prefetch assertion.

New on this head: The rebase updates the external-send ADR references without changing the Send screens, entry points, or tests. At head 1293a05, target membership, workflow lint, recovery, and the accessibility audit passed; the simulator suite was still pending. This review did not run a build, tests, or a device smoke test.

🔴 2 blocking | 🟡 3 suggestion(s)

5 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Entering the visible PIN after a lock-screen scan can lose the scanned payment
Impact: With biometrics disabled, a holder who scans from the lock screen and enters the PIN on its visible keypad unlocks the app without opening the scanned payment.
DashWallet/Sources/UI/LockScreen/DWLockScreenViewController.m:362-369

The visible keypad can unlock the wallet without handing off the scan. After Scan to Send accepts a code, DWBasePayViewController dismisses the scanner and re-enables interaction on the lock screen. The scan then starts a separate PIN prompt whose presenter prefers the attached app window beneath the lock window. The lock-screen keypad remains usable and, on a valid PIN, calls lockScreenViewControllerDidUnlock: directly. That path has no scan to deliver: only the separate prompt's success callback supplies deferredScannedInput. Queue the scan before starting authentication and let the existing lock-screen unlock consume it once; clear it on cancellation or wipe. Verify the handoff with biometrics disabled and both windows present.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🔴 Blocking: The scanner prefetch test fails on a clean mainnet test host
Impact: A clean simulator host rejects the positive test fixture as a wrong-network address, failing the first prefetch assertion.
DashWalletTests/ExternalSend/ExternalSendFlowTests.swift:598-600

testTheScannerPrefetchesOnlyARequestTheSendHonors fails at its first XCTAssertTrue when the test host has no saved chain selection. The fixture is encoded for testnet, but prefetchesPaymentRequest calls DestinationParser with the live WalletEnvironment.networkKind, which defaults to mainnet. The parser returns .wrongNetwork, so the predicate returns false before it can accept the request URL. Some negative cases can pass for that same unintended reason. Make the network explicit in the test and assert both same-network acceptance and wrong-network rejection without changing the production gate.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: A successful scan prompt does not prove the current wallet session is unlocked
Impact: If the app backgrounds during the scan-to-unlock handoff, the root can open balance-bearing Send UI or start a merchant request after the authorizing session has ended.
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:252-267

The scan handoff can use an authentication result that no longer represents the current session. The service clears didAuthenticate on backgrounding, but the asynchronous gate forwards its earlier .ok result without rechecking the session. The root then removes the lock window and launches the pending scan without the lock check used for URL replay. Presenting from mainController fixes which window owns Send, not whether the authorization is still current. Tie scan delivery to the active lock transition and recheck the session before removing the lock and before opening Send; leave the scan pending for a fresh unlock if that session ended.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Unlock can erase a payment link that the router just deferred again
Impact: A holder loses a pending payment link if the router still considers the wallet locked when the unlock completion replays it.
DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:500-503

A replay that gets deferred again disappears instead of waiting for the next unlock. handleURL: now writes to deferredURLToProcess and returns whenever the lock predicate is true, even when the slot is already populated. The completion at lines 500–503 calls that router and then clears the same slot. This can happen if the session relocks during the transition or the weak lockController still points to a retained controller. Take and clear the original URL before routing it, and retire the completed lock marker before replay so any new deferral survives.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: Tall Send sheets can clip content even at the end of scrolling
Impact: A holder reviewing tall Confirm or Send-failed content in a constrained presentation can reach the scroll limit without bringing the bottom controls fully into view.
DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift:175-195

The bottom controls can sit outside the visible scroll area even at the end of scrolling. The 92-point subtraction accounts for the pinned grabber and titled bar, but CappedSheetBody still fixes the scroll frame from 95% of the full key-window height. The pinned DashUIKit BottomSheet.selfSizing measures its ideal vertical size and requests a height detent; it does not resize this frame to the space iOS actually grants. When that space is shorter, the scroll limit is calculated against the oversized frame rather than the visible area. Size the scrolling viewport from the space actually available below the header and verify the final action is reachable in a short presentation with tall content.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: general, security-auditor)

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The diff changes funds movement even though it reuses the spend engine: SendAmountViewModel.proceed passes the source-specific amount and exact Shielded sweep credits into the new flow, and ConfirmViewModel.confirm owns the transition from a prepared payment to broadcast.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/LockScreen/DWLockScreenViewController.m`:
- [BLOCKING] DashWallet/Sources/UI/LockScreen/DWLockScreenViewController.m:362-369: Entering the visible PIN after a lock-screen scan can lose the scanned payment
  Impact: With biometrics disabled, a holder who scans from the lock screen and enters the PIN on its visible keypad unlocks the app without opening the scanned payment.
  The visible keypad can unlock the wallet without handing off the scan. After Scan to Send accepts a code, `DWBasePayViewController` dismisses the scanner and re-enables interaction on the lock screen. The scan then starts a separate PIN prompt whose presenter prefers the attached app window beneath the lock window. The lock-screen keypad remains usable and, on a valid PIN, calls `lockScreenViewControllerDidUnlock:` directly. That path has no scan to deliver: only the separate prompt's success callback supplies `deferredScannedInput`. Queue the scan before starting authentication and let the existing lock-screen unlock consume it once; clear it on cancellation or wipe. Verify the handoff with biometrics disabled and both windows present.

In `DashWalletTests/ExternalSend/ExternalSendFlowTests.swift`:
- [BLOCKING] DashWalletTests/ExternalSend/ExternalSendFlowTests.swift:598-600: The scanner prefetch test fails on a clean mainnet test host
  Impact: A clean simulator host rejects the positive test fixture as a wrong-network address, failing the first prefetch assertion.
  `testTheScannerPrefetchesOnlyARequestTheSendHonors` fails at its first `XCTAssertTrue` when the test host has no saved chain selection. The fixture is encoded for testnet, but `prefetchesPaymentRequest` calls `DestinationParser` with the live `WalletEnvironment.networkKind`, which defaults to mainnet. The parser returns `.wrongNetwork`, so the predicate returns `false` before it can accept the request URL. Some negative cases can pass for that same unintended reason. Make the network explicit in the test and assert both same-network acceptance and wrong-network rejection without changing the production gate.

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:252-267: A successful scan prompt does not prove the current wallet session is unlocked
  Impact: If the app backgrounds during the scan-to-unlock handoff, the root can open balance-bearing Send UI or start a merchant request after the authorizing session has ended.
  The scan handoff can use an authentication result that no longer represents the current session. The service clears `didAuthenticate` on backgrounding, but the asynchronous gate forwards its earlier `.ok` result without rechecking the session. The root then removes the lock window and launches the pending scan without the lock check used for URL replay. Presenting from `mainController` fixes which window owns Send, not whether the authorization is still current. Tie scan delivery to the active lock transition and recheck the session before removing the lock and before opening Send; leave the scan pending for a fresh unlock if that session ended.

In `DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m`:
- [SUGGESTION] DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:500-503: Unlock can erase a payment link that the router just deferred again
  Impact: A holder loses a pending payment link if the router still considers the wallet locked when the unlock completion replays it.
  A replay that gets deferred again disappears instead of waiting for the next unlock. `handleURL:` now writes to `deferredURLToProcess` and returns whenever the lock predicate is true, even when the slot is already populated. The completion at lines 500–503 calls that router and then clears the same slot. This can happen if the session relocks during the transition or the weak `lockController` still points to a retained controller. Take and clear the original URL before routing it, and retire the completed lock marker before replay so any new deferral survives.

In `DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmSheet.swift:175-195: Tall Send sheets can clip content even at the end of scrolling
  Impact: A holder reviewing tall Confirm or Send-failed content in a constrained presentation can reach the scroll limit without bringing the bottom controls fully into view.
  The bottom controls can sit outside the visible scroll area even at the end of scrolling. The 92-point subtraction accounts for the pinned grabber and titled bar, but `CappedSheetBody` still fixes the scroll frame from 95% of the full key-window height. The pinned DashUIKit `BottomSheet.selfSizing` measures its ideal vertical size and requests a height detent; it does not resize this frame to the space iOS actually grants. When that space is shorter, the scroll limit is calculated against the oversized frame rather than the visible area. Size the scrolling viewport from the space actually available below the header and verify the final action is reachable in a short presentation with tall content.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Round 10 (review at 1293a05), findings from the review body:

  • Conflict test read the host's network (blocking). Fixed in 65e1193: ExternalSendFlowTests asserts the dropped address, so it fails without the guard on mainnet and testnet; the scanner prefetch test pins testnet and checks mainnet too.
  • With biometrics off, the PIN prompt for a lock-screen scan sat under the lock window (blocking). Fixed in 65e1193: the root holds the scan before anything is asked, and the lock screen's own unlock (its keypad, or biometrics offered right away) opens it once. The separate prompt and ExternalSendLauncher.authenticateToUnlock are gone.
  • A scan handoff could open Send on a finished authentication. Fixed in 65e1193: the unlock delivers a held scan or link only while shouldShowLockScreen is false; otherwise both stay held for the next unlock.
  • A link replayed on unlock and deferred again was erased. Fixed in 65e1193: the held link is taken out before it is routed, and the lock markers are cleared before the replay.
  • CappedSheetBody sized from 95% of the window. Fixed in 65e1193: the body reads how far it reaches below the presented sheet's visible area and lowers its bound by that. Applied to Confirm, Send failed, Select source (which used BottomSheet.selfSizing without a bound) and feat(wallet): offer to finish a send whose asset lock is held #1423's held-lock sheet.

Stack order is now #1406 → #1407 → #1409 → #1502 (was #1486) → #1423 → #1501.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Changes requested: 2 blockers

  • Core-to-Identity rejects top-ups whose asset lock meets the SDK minimum — DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:443-445 (new; not shown inline, see below)
    Impact: A holder topping up their own Identity from Core cannot send a positive amount below 50,500 duffs, even if their wallet can fund the lock and the miner fee.
  • A failed fee retry leaves Send disabled without a visible Retry action — DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:586-596 (new; not shown inline, see below)
    Impact: A payer who retries while the fee or balance is still unavailable loses the Retry action and cannot use it once the connection recovers.

New on this head: This revision hands lock-screen scans to Send after the normal unlock, adds a fee-failure dialog, and updates sheet sizing, payment-link validation, and Core-to-Identity fee handling. On the exact head, recovery, workflow lint, test-target membership, and the VoiceOver/Dynamic Type audit passed; simulator tests were still queued, so this review did not verify device behavior or a funded send.

A pattern across this PR's review rounds

This is review round 14, and the PR has drawn 21 blocking findings so far. 4 of them share 2 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. Send is not fully owned by the wallet session (1 new in this round, 4 earlier finding(s))

The normal unlock now delivers scans without a separate PIN prompt, but DWAppRootViewController still keeps deferredScannedInput and deferredURLToProcess in separate slots with no shared replacement rule. The handoff fix moved the problem from losing a scan during unlock to letting an older scan displace a newer link. Once Send opens, ExternalSendFlow still ends with its host rather than with the wallet session.

Already tracked: #1450

In this round: An older lock-screen scan takes precedence over a newer payment link

2. Retry disappears while the failure remains (1 new in this round, 1 earlier finding(s))

SourceFacts now keeps an unreadable balance distinct from insufficient funds, but SendAmountStepScreen ties the only visible retry action to a once-per-streak dialog rather than to the persistent .feeFailed state. The dead end moved from the first failed balance read to a failed retry: Continue stays disabled after the dialog is gone.

In this round: A failed fee retry leaves Send disabled without a visible Retry action

Suggested decision (redesign the component): Finish the wallet-session part of ADR-0063 in #1409 rather than leaving it to #1450. Let the normal lock and unlock path own one pending payment intent, with the same replacement rule for scans and payment links, and hand it off once the wallet is unlocked. End unsubmitted Send attempts on relock instead of only covering their screens. The simulator test and review checks are still pending.

🔴 2 blocking | 🟡 1 suggestion(s)

3 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Core-to-Identity rejects top-ups whose asset lock meets the SDK minimum
Impact: A holder topping up their own Identity from Core cannot send a positive amount below 50,500 duffs, even if their wallet can fund the lock and the miner fee.
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:443-445

A funded 50,000-duff top-up shows “below minimum” and disables Continue; Max also stops here when it leaves a positive amount below that threshold. The screen still compares the recipient amount to the SDK floor, but the rebased LiveCoreTwoStepSend.toIdentity adds 50,500 duffs of Platform fee before calling topUpIdentityWithFunding, so this top-up would produce a 100,500-duff lock. At the pinned Platform commit 6e113dc8, identity_top_up.rs applies the 50,500-duff floor to that lock, not to what the holder enters. Check the computed lock in a shared policy used by both Send and ExternalSendExecutor.minimumAmountRefusal; changing only the screen would move the rejection to dispatch. Update the tests that assert a recipient-amount floor and cover a funded small top-up with the live fee policy.

Raised on code unchanged since the last review, and confirmed by an independent pass: A user with enough spendable Core funds can enter 50,000 duffs in Send to top up their own Current identity, but the screen reports that the amount is below the minimum and disables Continue. The rebased funding code would add a 50,500-duff Platform fee and pass a 100,500-duff lock to the SDK, so the UI rejects a top-up that meets the SDK's minimum.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🔴 Blocking: A failed fee retry leaves Send disabled without a visible Retry action
Impact: A payer who retries while the fee or balance is still unavailable loses the Retry action and cannot use it once the connection recovers.
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:586-596

On a verified invoice, a payer who taps Try again before the wallet or connection recovers is left with a disabled Continue button and no visible explanation or Retry action. retryFee() closes the dialog before rereading the source; a second failure leaves the model in .feeFailed, but isFeeFailureStreakReported prevents the dialog from reopening. This revision removed the inline Retry, and the locked invoice has no keypad or Max and only one available source. Reselecting Core can trigger another read, but the screen gives no indication to do that. Keep the once-per-streak dialog if desired, but leave a visible error and Retry while .feeFailed persists, as AC-01b requires. Cover failure, a failed Retry, and recovery on the same locked invoice.

Confirmed by an independent pass: A payer who opens a verified invoice while the Core balance or fee is unavailable can tap Try again before the wallet is ready. If the read fails again, the dialog stays closed and Continue remains disabled, leaving the locked invoice with no visible fee error or Retry action even after the wallet recovers.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

🟡 Suggestion: An older lock-screen scan takes precedence over a newer payment link
Impact: A holder who scans an invoice without unlocking and later opens another merchant’s link can be shown the old invoice instead.
DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:501-510

The new handoff can open Send for the wrong payment intent. A scan now stays pending before authentication. If the holder leaves without unlocking and later opens another payment link, handleURL: records the new URL but leaves the old scan in its separate slot. On unlock, the root clears both slots and always presents the scan first, silently dropping the newer link. No funds move without confirmation. Give the root one pending payment entry, or supersede the older payment entry on arrival, and test that scan → later link → unlock shows the newer recipient.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

Follow-up candidates (optional) (2)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Show clipboard can drop a payment link that Address still accepts
Impact: A payer using Show clipboard can be told there is no payment link when the copied link contains a multiword label that works when pasted directly.
DashWallet/Sources/UI/Payments/ExternalSend/Address/AddressViewModel.swift:112-118

A complete link such as one ending in ?label=Coffee Shop&amount=1 is accepted by DestinationParser.parse, including the full label and amount, but Show clipboard now reports that it found nothing. Address calls DestinationParser.find, which used to try the whole clipboard first. The rebased helper instead splits it into words and skips the first word because Shop&amount=1 looks like a query continuation. Preserve whole-link parsing when it succeeds without the new malformed-query flags, and use the continuation rules for extraction from surrounding prose. Cover the complete link through Show clipboard, not just through the parser.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

🟡 Suggestion: Pasting a multiline payment link into Address can change the amount
Impact: A payer who pastes a link with a line break inside the amount can see Send prefilled with a different amount instead of an invalid-link error.
DashWallet/Sources/UI/Payments/ExternalSend/Address/AddressViewModel.swift:96-103

Send can prefill 10 DASH from a copied link whose amount value is 1 followed by a line break and 0. The editable AddressFieldView uses a multiline text field bound to setText, which removes every line break before Continue calls DestinationParser. The rebased parser now rejects embedded query newlines through hasMalformedQuery, but Address hands it amount=10, so that guard never fires. Confirm is still required, but it reviews the rewritten amount, not the pasted one. Keep Return-to-dismiss behavior without flattening interior line breaks in links, and cover ordinary field paste in the regression test.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — ConfirmViewModel.swift and ExternalSendFlow.swift implement an intricate prepare-to-broadcast lifecycle and govern when a payment can be retried, directly changing funds-movement behavior even though the underlying spend services are reused.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • New since the last final review (1293a057): 3 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 2 confirmed, 1 not confirmed (no longer blocking); 1 suggestion(s) on unchanged code listed as follow-up candidates
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): Send is not fully owned by the wallet session; Retry disappears while the failure remains. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Finish the wallet-session part of ADR-0063 in #1409 rather than leaving it to #1450. Let the normal lock and unlock path own one pending payment intent, with the same replacement rule for scans and payment links, and hand it off once the wallet is unlocked. End unsubmitted Send attempts on relock instead of only covering their screens. The simulator test and review checks are still pending. If that decision is not yours to make, say so to the PR's author or maintainer.

These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:443-445: Core-to-Identity rejects top-ups whose asset lock meets the SDK minimum
  Impact: A holder topping up their own Identity from Core cannot send a positive amount below 50,500 duffs, even if their wallet can fund the lock and the miner fee.
  A funded 50,000-duff top-up shows “below minimum” and disables Continue; Max also stops here when it leaves a positive amount below that threshold. The screen still compares the recipient amount to the SDK floor, but the rebased `LiveCoreTwoStepSend.toIdentity` adds 50,500 duffs of Platform fee before calling `topUpIdentityWithFunding`, so this top-up would produce a 100,500-duff lock. At the pinned Platform commit `6e113dc8`, `identity_top_up.rs` applies the 50,500-duff floor to that lock, not to what the holder enters. Check the computed lock in a shared policy used by both Send and `ExternalSendExecutor.minimumAmountRefusal`; changing only the screen would move the rejection to dispatch. Update the tests that assert a recipient-amount floor and cover a funded small top-up with the live fee policy.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: A user with enough spendable Core funds can enter 50,000 duffs in Send to top up their own Current identity, but the screen reports that the amount is below the minimum and disables Continue. The rebased funding code would add a 50,500-duff Platform fee and pass a 100,500-duff lock to the SDK, so the UI rejects a top-up that meets the SDK's minimum._
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:586-596: A failed fee retry leaves Send disabled without a visible Retry action
  Impact: A payer who retries while the fee or balance is still unavailable loses the Retry action and cannot use it once the connection recovers.
  On a verified invoice, a payer who taps Try again before the wallet or connection recovers is left with a disabled Continue button and no visible explanation or Retry action. `retryFee()` closes the dialog before rereading the source; a second failure leaves the model in `.feeFailed`, but `isFeeFailureStreakReported` prevents the dialog from reopening. This revision removed the inline Retry, and the locked invoice has no keypad or Max and only one available source. Reselecting Core can trigger another read, but the screen gives no indication to do that. Keep the once-per-streak dialog if desired, but leave a visible error and Retry while `.feeFailed` persists, as AC-01b requires. Cover failure, a failed Retry, and recovery on the same locked invoice.

  _Confirmed by an independent pass: A payer who opens a verified invoice while the Core balance or fee is unavailable can tap Try again before the wallet is ready. If the read fails again, the dialog stays closed and Continue remains disabled, leaving the locked invoice with no visible fee error or Retry action even after the wallet recovers._

In `DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m`:
- [SUGGESTION] DashWallet/Sources/UI/RootNavigation/DWAppRootViewController.m:501-510: An older lock-screen scan takes precedence over a newer payment link
  Impact: A holder who scans an invoice without unlocking and later opens another merchant’s link can be shown the old invoice instead.
  The new handoff can open Send for the wrong payment intent. A scan now stays pending before authentication. If the holder leaves without unlocking and later opens another payment link, `handleURL:` records the new URL but leaves the old scan in its separate slot. On unlock, the root clears both slots and always presents the scan first, silently dropping the newer link. No funds move without confirmation. Give the root one pending payment entry, or supersede the older payment entry on arrival, and test that scan → later link → unlock shows the newer recipient.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • An expired unlock completion can still announce an unlock — The new session check protects delivery of a pending payment, but the root still hides the lock window before that check and posts DWAppDidUnlockNotification even when the session requires another unlock. Both behaviors predate this PR and also affect ordinary unlocks without a pending payment.
    • Follow-up: Verify foregrounding during an interrupted unlock with immediate auto-lock in a separate root-lifecycle PR, and keep the lock view and unlock notification consistent with the session at completion.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Round on 65e1193, now at d522a43 (rebased; String Catalog as on #1406):

  • Core-to-Identity minimum (blocking). Fixed in d522a43 with f048f40: Send and the dispatch check read one function that compares the lock (amount + Platform fee) with the SDK minimum. A funded 50,000-duff top-up continues, and so does a Max under the old floor. Tests: testASmallCoreToIdentityAmountWhoseLockMeetsTheMinimumContinues, testACoreToIdentityMaxBelowTheOldAmountFloorContinues.
  • Retry after a failed fee retry (blocking). Fixed in d522a43: while the fee or the balance cannot be read, Send keeps the error and offers Try again whenever the dialog is closed (isFeeRetryOffered); the dialog still shows once per streak. Applied to the amount step's failure states, including an unreadable balance with no amount typed, which used to read as an empty amount. Tests: testALockedInvoiceKeepsTheFeeErrorAndRetryUntilTheReadRecovers (failure, failed retry, recovery on a verified invoice), testAnUnreadableBalanceWithNoAmountIsAFeeFailureWithRetry.
  • Older scan over a newer link. Fixed in d522a43: the root holds one payment entry for the unlock (heldPaymentEntry), a link or a scan, and the newest replaces the older. Wipe clears it. Ending Send on relock stays in External send: one lifecycle owner, a typed scan result and a source snapshot with unknown balances #1450. The UIKit root has no unit harness, so this goes into the Maestro regression flows.
  • Follow-ups (Show clipboard, multiline paste): fixed with the clipboard rule; see the DestinationParser.find thread on feat(wallet): domain model for sending to any destination #1406.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

Changes requested: 2 blockers

  • Unsigned invoices show issuer-supplied names and notes without an unverified label — DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:663-670 (new)
    Impact: A wallet holder opening an unsigned invoice can mistake the issuer's self-reported name or memo for information the wallet has verified.
  • Invoice fees do not count against the biometric spending limit in the new Send flow — DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m:109-115 (new)
    Impact: A wallet holder with biometric spending enabled can approve an invoice without a PIN when the invoice amount fits the remaining allowance but the fee-inclusive debit does not.

New on this head: This revision rebases the new Send screens and entry points, keeps one pending payment entry while the wallet is locked, leaves fee retries available after a failed read, and checks the Core-to-Identity minimum against the asset-lock amount. On this exact head, test-target membership, workflow lint, and the accessibility audit passed; simulator tests and recovery were still pending when checked.

A pattern across this PR's review rounds

This is review round 15, and the PR has drawn 23 blocking findings so far. 3 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. Invoice approval is not shared (2 new in this round, 1 earlier finding(s))

ExternalSend reuses BIP70 fetching and sending, but not the approval rules in DWPaymentOutput and DWPaymentProcessor. ExternalSendFlow.requestDestination presents invoice details through the same fields as an ordinary address link, while LiveCorePaymentRequestSend authorizes the invoice amount without the fee. That is why rebasing onto #1369 brought in both protections without applying either to the replacement flow.

Already tracked: #1416

In this round: Unsigned invoices show issuer-supplied names and notes without an unverified label; Invoice fees do not count against the biometric spending limit in the new Send flow

Suggested decision (land the prerequisite first): Land one shared interactive BIP70 approval policy before #1409 takes over invoice entry points, so both flows distinguish unverified invoice text and authorize the fee-inclusive debit. If that prerequisite does not land first, keep invoices on the existing BIP70 path and switch only direct payments to the new screens. Leave the deferred recipient breakdown in #1416. The simulator tests, recovery check, and review check are still pending.

🔴 2 blocking | 🟡 1 suggestion(s)

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Confirm shows one address even when an invoice pays several
Impact: A wallet holder who opens a multi-address invoice from a QR code or link can approve the full amount without seeing that it is split among recipients.
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:299-303

The new Confirm screen does not disclose that part of the displayed total goes to another address. Scanning or opening a valid BIP70 invoice with multiple distinct recipients reaches ExternalSend; the interactive policy accepts those requests, including unsigned ones. requestDestination pairs the primary address with the aggregate amount, and expanding the To row adds only that address and the request URL. Confirm then sends the prepared transaction that BIP70PaymentService.buildForSend built from every recipient in the box. This is a new regression against the rebased base: #1369 (085182e10) made the legacy confirmation show the recipient count and, for an unsigned request, each address and its subtotal. Preserve those disclosures in the replacement screen using BIP70ConfirmationBox, and cover an unsigned invoice with two distinct addresses and amounts.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — ConfirmViewModel.swift and ExternalSendFlow.swift add intricate funds-movement orchestration that controls which prepared payment is broadcast after confirmation and when a failed attempt can be retried.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • New since the last final review (65e11933): 3 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 2 confirmed, 1 not confirmed (no longer blocking)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): Invoice approval is not shared. When you fix the findings below, fix the cause, not only the reported case. The review suggests (land the prerequisite first): Land one shared interactive BIP70 approval policy before #1409 takes over invoice entry points, so both flows distinguish unverified invoice text and authorize the fee-inclusive debit. If that prerequisite does not land first, keep invoices on the existing BIP70 path and switch only direct payments to the new screens. Leave the deferred recipient breakdown in #1416. The simulator tests, recovery check, and review check are still pending. If that decision is not yours to make, say so to the PR's author or maintainer.

These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:663-670: Unsigned invoices show issuer-supplied names and notes without an unverified label
  Impact: A wallet holder opening an unsigned invoice can mistake the issuer's self-reported name or memo for information the wallet has verified.
  The replacement Send and Confirm screens remove the explicit trust distinction introduced by #1369 on the rebased base. A valid unsigned invoice opened by QR code or link can carry a self-reported merchant name and memo; fetching it successfully does not authenticate either. `label(of:)` returns the sanitized name without an unverified label, or no label if the name is absent. `note(of:)` only sanitizes the memo, and Confirm renders it in a wallet information row without the legacy prefix, single-line treatment, or length cap. Reuse the unsigned-invoice presentation rules in both screens, including the unnamed case, without changing ordinary address-link labels. Update the flow test that currently expects `Merchant` alone for an unsigned invoice.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: A user who scans or opens a valid unsigned BIP70 invoice with a name and memo supplied by its issuer sees that name in Send and Confirm and the memo as ordinary information, without an explicit unverified label. The user can approve the payment without being told that neither the claimed recipient identity nor the note was authenticated._

In `DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m`:
- [BLOCKING] DashWallet/Sources/UI/Payments/Pay/DWBasePayViewController.m:109-115: Invoice fees do not count against the biometric spending limit in the new Send flow
  Impact: A wallet holder with biometric spending enabled can approve an invoice without a PIN when the invoice amount fits the remaining allowance but the fee-inclusive debit does not.
  The new QR and link entry points can authorize a larger debit than the remaining biometric allowance. A funded invoice sent through these entry points reaches `LiveCorePaymentRequestSend.preparePaymentRequestSend` on Continue, which authorizes `confirmation.amount` before building the transaction. `AuthenticationService` uses that value both to decide whether to require a PIN and to subtract from the allowance. The subsequent `requireFits` check only tests available funds, and Confirm does not reauthorize the prepared debit. On the rebased base, #1369 changed `DWPaymentProcessor.broadcastBIP70PaymentOutput:` to authorize the amount plus the displayed estimated fee. Restore fee-inclusive authorization in the adapter with checked arithmetic, ensure the prepared debit cannot exceed what the gate authorized, and add an allowance-boundary regression test.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: With biometrics enabled and sufficient Core funds, a user can open an unsigned BIP70 invoice whose amount fits the remaining biometric allowance but whose fee-inclusive debit exceeds it. Continue obtains biometric approval and deducts only the invoice amount from the allowance; Confirm then sends the fee-inclusive transaction without the PIN that the larger debit should require._

In `DashWallet/Sources/UI/Payments/ExternalSend/Address/AddressViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Address/AddressViewModel.swift:102-103: Editing a payment link drops spaces between words in its label or message
  Impact: A user editing a multiword label or message in the Address field can end up with joined words, even though pasting the same complete link preserves the space.
  The Address field can lose a separator the user just typed. `AddressScreen` sends every text edit to `setText`, and the new payment-scheme branch writes the trimmed value back to the binding. An intermediate edit ending in `label=Coffee ` is therefore stored as `label=Coffee`, while a whole paste of `label=Coffee Shop` keeps the interior space. Use the trimmed copy to detect the scheme, strip a terminal Return separately, and let the parser trim outer whitespace at submission. Add a test that feeds the intermediate edits through the binding, not just the completed link.

Comment on lines +663 to +670
/// The label, sanitized and prefixed with 🔒 when a payment request's merchant verified, as the old Send does.
static func label(of destination: Destination) -> String? {
guard let label = sanitized(destination.label) else { return nil }
return destination.isVerifiedMerchant ? "🔒 " + label : label
}

static func note(of destination: Destination) -> String? {
sanitized(destination.message)

@thepastaclaw thepastaclaw Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 8444f063; see the replies below.

🔴 Blocking: Unsigned invoices show issuer-supplied names and notes without an unverified label
Impact: A wallet holder opening an unsigned invoice can mistake the issuer's self-reported name or memo for information the wallet has verified.

The replacement Send and Confirm screens remove the explicit trust distinction introduced by #1369 on the rebased base. A valid unsigned invoice opened by QR code or link can carry a self-reported merchant name and memo; fetching it successfully does not authenticate either. label(of:) returns the sanitized name without an unverified label, or no label if the name is absent. note(of:) only sanitizes the memo, and Confirm renders it in a wallet information row without the legacy prefix, single-line treatment, or length cap. Reuse the unsigned-invoice presentation rules in both screens, including the unnamed case, without changing ordinary address-link labels. Update the flow test that currently expects Merchant alone for an unsigned invoice.

Raised on code unchanged since the last review, and confirmed by an independent pass: A user who scans or opens a valid unsigned BIP70 invoice with a name and memo supplied by its issuer sees that name in Send and Confirm and the memo as ordinary information, without an explicit unverified label. The user can approve the payment without being told that neither the claimed recipient identity nor the note was authenticated.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8444f06: every screen that presents a fetched payment request for approval shows it under one set of rules, BIP70InteractivePolicy (recipientName, note, recipientsNotice):

  • An unsigned request's name reads "Unverified recipient: ", or "Unverified recipient" when it sends none.
  • Its note reads "Unverified note: …", on one line and capped at 140.
  • A signed name keeps 🔒.
  • A request paying several addresses says how many; an unsigned one lists each address with its amount.

Applied at:

  • the old confirm screen (DWPaymentOutput+DWView.m, whose private copy of these rules is removed);
  • Send's title and note (SendAmountViewModel.label(of:), note(of:));
  • Confirm's To row, note and the new recipients line (ConfirmViewModel).

Ordinary address links keep their own label rules.

Tests: testAnUnsignedPaymentRequestShowsItsNameAndNoteAsUnverified (named and unnamed; the flow test that expected Merchant is updated), testAnUnsignedPaymentRequestIsLabelledUnverifiedAndListsEveryAddress (Confirm: two addresses, multi-line long note), and the old screen's BIP70PaymentServiceTests, unchanged and green.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 8444f063): I verified that Send and Confirm use BIP70InteractivePolicy for fetched invoices, including unnamed unsigned recipients and labelled, flattened, capped unsigned notes. Ordinary address-link labels and messages still use their separate path.

Comment on lines +109 to 115
- (void)presentScannedPaymentInput:(DWPaymentInput *)paymentInput {
[DWExternalSendLauncher presentScanned:paymentInput from:self];
}

- (void)performPayToURL:(NSURL *)url {
[DWExternalSendLauncher presentLink:url from:self];
}

@thepastaclaw thepastaclaw Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 8444f063; see the replies below.

🔴 Blocking: Invoice fees do not count against the biometric spending limit in the new Send flow
Impact: A wallet holder with biometric spending enabled can approve an invoice without a PIN when the invoice amount fits the remaining allowance but the fee-inclusive debit does not.

The new QR and link entry points can authorize a larger debit than the remaining biometric allowance. A funded invoice sent through these entry points reaches LiveCorePaymentRequestSend.preparePaymentRequestSend on Continue, which authorizes confirmation.amount before building the transaction. AuthenticationService uses that value both to decide whether to require a PIN and to subtract from the allowance. The subsequent requireFits check only tests available funds, and Confirm does not reauthorize the prepared debit. On the rebased base, #1369 changed DWPaymentProcessor.broadcastBIP70PaymentOutput: to authorize the amount plus the displayed estimated fee. Restore fee-inclusive authorization in the adapter with checked arithmetic, ensure the prepared debit cannot exceed what the gate authorized, and add an allowance-boundary regression test.

Raised on code unchanged since the last review, and confirmed by an independent pass: With biometrics enabled and sufficient Core funds, a user can open an unsigned BIP70 invoice whose amount fits the remaining biometric allowance but whose fee-inclusive debit exceeds it. Continue obtains biometric approval and deducts only the invoice amount from the allowance; Confirm then sends the fee-inclusive transaction without the PIN that the larger debit should require.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1b6e065 (#1407, where LiveCorePaymentRequestSend lives): the prompt for a payment request is given what the send debits. The request is built and signed first, with nothing broadcast. The prompt then gets the request's amount plus the fee of that built transaction, checked for overflow. The prepared send broadcasts the same built transaction, so the debit cannot exceed what was authorized. A refused prompt releases the request for the next attempt. This is stricter than the old path's amount + estimated fee, whose one-input estimate can be below the real fee. Every QR, link and lock-screen entry that opens an invoice in the new flow reaches this one adapter. Tests: LiveCorePaymentRequestSendTests (prompt gets 100,000 + 1,234; a refused prompt broadcasts nothing and the request can be built again; a debit beyond UInt64 is never authorized).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 8444f063): I traced the new entry points through Continue to the adapter in #1407. It authorizes the checked sum of the invoice amount and the built fee, passes that same transaction to Confirm, and releases the claim on refusal without posting or broadcasting.

Comment on lines +102 to +103
let trimmed = newText.trimmingCharacters(in: .whitespacesAndNewlines)
text = DestinationParser.startsWithPaymentScheme(trimmed) ? trimmed : lines.joined()

@thepastaclaw thepastaclaw Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Resolved at 8444f063; see the replies below.

🟡 Suggestion: Editing a payment link drops spaces between words in its label or message
Impact: A user editing a multiword label or message in the Address field can end up with joined words, even though pasting the same complete link preserves the space.

The Address field can lose a separator the user just typed. AddressScreen sends every text edit to setText, and the new payment-scheme branch writes the trimmed value back to the binding. An intermediate edit ending in label=Coffee is therefore stored as label=Coffee, while a whole paste of label=Coffee Shop keeps the interior space. Use the trimmed copy to detect the scheme, strip a terminal Return separately, and let the parser trim outer whitespace at submission. Add a test that feeds the intermediate edits through the binding, not just the completed link.

source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8444f06: a link typed or pasted into Address keeps its spaces; only line breaks at its ends are dropped, and the parser trims the ends when the link is read. Return still ends editing, and an address split across lines is still joined. Test: testTypingALinkKeepsTheSpaceBetweenTheWordsOfItsLabel, which feeds the link one character at a time through setText.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 8444f063): I verified that setText now uses the trimmed copy only to detect the scheme. The character-by-character regression test exercises the intermediate trailing space and checks that the submitted label still reads Coffee Shop.

@romchornyi
romchornyi force-pushed the feat/external-send-screens branch from d522a43 to 8444f06 Compare November 27, 2026 01:32
@romchornyi

Copy link
Copy Markdown
Contributor Author

Round 12, head 8444f06. The pattern "invoice approval is not shared" is closed at its cause:

  1. One presentation for every screen that approves a fetched request, BIP70InteractivePolicy (recipientName, note, recipientsNotice). It covers:

    • the unverified name, including when the request sends none;
    • the unverified note, on one line and capped;
    • the address count, and for an unsigned request each address with its amount.

    The old confirm screen and the new Send and Confirm all read it. The old screen's private copy is removed.

  2. One fee-inclusive authorization for an invoice, in feat(wallet): send services, asset-lock recovery and payment-request checks #1407's LiveCorePaymentRequestSend.

The follow-up candidate (several addresses on Confirm) is covered by (1). Also fixed: typing a link into Address no longer drops the space in a label.

Not changed, develop code outside the stack:

  • NFC still uses the old processor. It authorizes amount + estimated fee before building.
  • DashSpend's headless purchase authorizes the amount only.

Replies are on the threads.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

New on this head: On this head, Address preserves spaces while a payment link is being edited, and the new and legacy approval screens share invoice trust labels and recipient disclosure rules. The rebased services commit authorizes the invoice amount plus the fee of the transaction Confirm submits. Target membership, workflow lint, and accessibility checks passed; simulator tests and recovery checks are pending, and funded end-to-end sends remain unverified.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — ExternalSendFlow.swift and ConfirmViewModel.swift change how authenticated spends are prepared, confirmed, broadcast, and retried across multiple funding sources, making this an intricate funds-movement change even though it reuses existing spend services.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

Comment on lines +663 to +670
/// The label, sanitized and prefixed with 🔒 when a payment request's merchant verified, as the old Send does.
static func label(of destination: Destination) -> String? {
guard let label = sanitized(destination.label) else { return nil }
return destination.isVerifiedMerchant ? "🔒 " + label : label
}

static func note(of destination: Destination) -> String? {
sanitized(destination.message)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 8444f063): I verified that Send and Confirm use BIP70InteractivePolicy for fetched invoices, including unnamed unsigned recipients and labelled, flattened, capped unsigned notes. Ordinary address-link labels and messages still use their separate path.

Comment on lines +109 to 115
- (void)presentScannedPaymentInput:(DWPaymentInput *)paymentInput {
[DWExternalSendLauncher presentScanned:paymentInput from:self];
}

- (void)performPayToURL:(NSURL *)url {
[DWExternalSendLauncher presentLink:url from:self];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 8444f063): I traced the new entry points through Continue to the adapter in #1407. It authorizes the checked sum of the invoice amount and the built fee, passes that same transaction to Confirm, and releases the claim on refusal without posting or broadcasting.

Comment on lines +102 to +103
let trimmed = newText.trimmingCharacters(in: .whitespacesAndNewlines)
text = DestinationParser.startsWithPaymentScheme(trimmed) ? trimmed : lines.joined()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved (re-reviewed at 8444f063): I verified that setText now uses the trimmed copy only to detect the scheme. The character-by-character regression test exercises the intermediate trailing space and checks that the submitted label still reads Coffee Shop.

The new Send flow on top of the domain model and services: Address (paste,
scan, clipboard, Identity lookup), Select source, the amount step with Max,
Confirm with the fee and warnings, and the sending, in-progress and failed
outcomes. It opens from the Payments send menu, the balance rows, the QR
scanner (an Identity ID is accepted) and dash: links, and the old Send keeps
contact payments. The Internal transfer sheet no longer has a send-from mode,
since the balance-row Send opens the new flow.

The public summary is docs/features/external-send/README.md; the decisions
(ADR-0036 to ADR-0045) came with the domain model.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
SDD-Published-From: 693aa5b981459c58bd877c33a15775177e39af91
@romchornyi
romchornyi force-pushed the feat/external-send-screens branch from 8444f06 to 6bf692e Compare November 27, 2026 06:26

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants