Skip to content

feat(wallet): offer to finish a send whose asset lock is held - #1423

Draft
romchornyi wants to merge 1 commit into
feat/external-send-platform-identityfrom
feat/external-send-lock-held
Draft

romchornyi wants to merge 1 commit into
feat/external-send-platform-identityfrom
feat/external-send-lock-held

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Closes #1422. A Core → Platform address or Core → Shielded send whose Platform step failed after the asset lock was broadcast and recorded was reported as "Send in progress. It will finish on its own", but nothing finished it: only Rebroadcast in the transaction details resumes such a lock.

Stacked on #1502 (base feat/external-send-platform-identity).

What was done?

  • SendOutcome.lockHeld(HeldAssetLock) (funding type, txid, vout): set only when the coordinator recorded the lock it built and the second step did not complete. .inFlight keeps meaning "submitted, result unknown".
  • New SwiftUI SendLockHeldSheet + SendLockHeldViewModel: "Transfer not finished — Your Dash is held for this transfer. Finish it now, or later from the transaction details."
    • Finish runs the same resume as Rebroadcast (AssetLockRecoveryService.retry, which asks for the PIN): completed → "Sent" toast; already spent / waiting for sync → the same info toasts Rebroadcast shows; PIN cancelled → the sheet stays; other error → a generic message, Finish can run again.
    • Close (or swipe down) ends the flow; both are disabled while Finish runs.
    • One DWLogger line per Finish: funding type, outcome, error type.
  • 4 new strings, in English in every locale.

Not covered: Core → Identity still reports .inFlight, because topUpIdentityWithFunding returns no outpoint to resume. No launch-time resume (waits for dashpay/platform#5824, the recipient recorded with the lock).

How Has This Been Tested?

  • ExternalSend unit tests: 653 green (642 before + 11 new: executor mapping, router destination, flow, Finish against a fake resume seam).
  • scripts/ci/check_test_target_membership.py and scripts/a11y_audit.py --check pass.
  • Maestro flow still to write (draft): a Debug fault switch stops the send after the lock; the sheet appears, Close ends the flow, Finish with PIN cancelled keeps the sheet, Finish completes with the "Sent" toast, a forced resume error shows the message.

Breaking Changes

None.

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
  • ADR (ADR-0001): to decide before review — this adds a fourth send outcome to the model of ADR-0040 (Proposed)
  • Nothing in this PR (files, commit messages, branch name, description, comments, attachments, linked issues) holds customer data, unfixed vulnerability detail, secrets, or step-by-step attack detail against keys, PIN or encryption; such content is left out and handled privately with the maintainers (ADR-0001, rule 2)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@romchornyi
romchornyi marked this pull request as ready for review November 14, 2026 01:48
@thepastaclaw

thepastaclaw commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 888305c. Normal review starts when eligible; priority review starts as soon as a slot is available.

@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 lock-held outcome is wired coherently through the executor, router, flow, sheet, and existing recovery service. Static verification finds two blocking issues: the new ViewModel omits Combine despite using ObservableObject and Published, and the externally visible fourth outcome is not recorded in the ADR or feature documentation required by the repository rules. The production resumer is covered only through a fake in the new tests; the simulator test remains in progress, so no CI result is available yet.

🔴 2 blocking | 🟡 1 suggestion(s)

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: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a cross-cutting behavioral change spanning send outcome handling, asset-lock recovery, SwiftUI flow state, localization, project configuration, and tests, but it does not directly alter the critical funds-movement implementation itself.
  • 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)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (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/Payments/ExternalSend/Sending/SendLockHeldViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Sending/SendLockHeldViewModel.swift:18: Import Combine for ObservableObject and Published
  This new source imports only Foundation but declares SendLockHeldViewModel as ObservableObject and uses @Published. Both symbols are provided by Combine, which Foundation does not re-export, so the app target cannot compile this file. Add the missing import before Foundation.
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Sending/SendLockHeldViewModel.swift:28-31: Exercise the production lock-resume path
  The new ViewModel tests inject a fake HeldAssetLockResuming, so they do not verify that LiveHeldAssetLockResumer passes the captured outpoint into AssetLockRecoveryService.retry, that funding types 4 and 5 select the correct resume routes, or that the real recovery result and authorization behavior work with the persisted lock and recipient records. This is the new Finish action for a money-moving flow. Add a focused funded-wallet simulator or integration check covering Finish success, PIN cancellation, and recovery for the affected funding types.

In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:41-43: Record and document lockHeld as the fourth send outcome
  This change adds lockHeld as a fourth externally visible send outcome, but ADR-0040 still chooses exactly three outcomes and the external-send feature summary still describes only sent, not sent, and in progress. That is a cross-module payment-state contract change affecting the executor, router, flow, and UI. Under ADR-0001, the decision must be recorded in the same PR: revise the Proposed decision or add a superseding Proposed ADR, update docs/adr/README.md, and update the feature summary so it no longer claims that every post-source failure finishes on its own.
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.

  • Track the Core-to-Identity held-lock recovery gap — The Core-to-Identity path still maps a post-lock failure from topUpIdentityWithFunding to inFlight, whose existing UI promises that the transfer will finish on its own. The new lock-held sheet cannot handle that route because the SDK call does not return an asset-lock outpoint; this is an adjacent pre-existing limitation rather than a regression in the changed routes, but the misleading state should not be left untracked.
    • Follow-up: Create or link a follow-up issue for Core-to-Identity held-lock recovery or an honest non-resuming result once the SDK exposes the required outpoint and recipient data.

// limitations under the License.
//

import Foundation

@thepastaclaw thepastaclaw Nov 14, 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 5ce63dab; see the replies below.

🔴 Blocking: Import Combine for ObservableObject and Published

This new source imports only Foundation but declares SendLockHeldViewModel as ObservableObject and uses @published. Both symbols are provided by Combine, which Foundation does not re-export, so the app target cannot compile this file. Add the missing import before Foundation.

Suggested change
import Foundation
import Combine
import Foundation

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

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 d868dff. The file now imports Combine, like the other External Send view models.

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 5ce63dab): SendLockHeldViewModel.swift now imports Combine before Foundation, providing the ObservableObject and Published declarations required by the app target.

Comment on lines +41 to +43
/// The money left the source into an asset lock that is recorded, and the Platform step did not finish: it stays
/// in the lock until the lock is resumed.
case lockHeld(HeldAssetLock)

@thepastaclaw thepastaclaw Nov 14, 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 5ce63dab; see the replies below.

🔴 Blocking: Record and document lockHeld as the fourth send outcome

This change adds lockHeld as a fourth externally visible send outcome, but ADR-0040 still chooses exactly three outcomes and the external-send feature summary still describes only sent, not sent, and in progress. That is a cross-module payment-state contract change affecting the executor, router, flow, and UI. Under ADR-0001, the decision must be recorded in the same PR: revise the Proposed decision or add a superseding Proposed ADR, update docs/adr/README.md, and update the feature summary so it no longer claims that every post-source failure finishes on its own.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)

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 d868dff. ADR-0040 (still Proposed) now records the fourth outcome, lockHeld, and its Finish resume. The index row and the feature summary describe four outcomes and no longer say that every failure after the money left finishes on its own. The file name stays the same so existing links keep working.

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 5ce63dab): The original cross-module documentation omission is fixed: ADR-0040 now records lockHeld and its Finish behavior, the ADR index reflects the updated title, and the external-send feature summary describes all four outcomes. The remaining stale sentence is a narrower documentation inconsistency reported separately on this head.

Comment on lines +28 to +31
struct LiveHeldAssetLockResumer: HeldAssetLockResuming {
func resume(_ lock: HeldAssetLock) async throws -> AssetLockRecoveryService.Outcome {
try await AssetLockRecoveryService().retry(
fundingTypeRaw: lock.fundingTypeRaw, txidWire: lock.txidWire, vout: lock.vout)

@thepastaclaw thepastaclaw Nov 14, 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.

⏭️ Deferred (maintainer decision; not blocking) at 5ce63dab; see the replies below.

🟡 Suggestion: Exercise the production lock-resume path

The new ViewModel tests inject a fake HeldAssetLockResuming, so they do not verify that LiveHeldAssetLockResumer passes the captured outpoint into AssetLockRecoveryService.retry, that funding types 4 and 5 select the correct resume routes, or that the real recovery result and authorization behavior work with the persisted lock and recipient records. This is the new Finish action for a money-moving flow. Add a focused funded-wallet simulator or integration check covering Finish success, PIN cancellation, and recovery for the affected funding types.

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

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.

Partly fixed in d868dff: LiveHeldAssetLockResumer now takes its retry as a seam, and a test checks that it passes the held outpoint and funding type (4 and 5) to the retry. Deferred: Finish against a real build (success, PIN cancel, both funding types) will be a Maestro flow with a Debug fault switch after the lock, tracked in #1422.

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.

Deferred (re-reviewed at 5ce63dab): The new seam test verifies that LiveHeldAssetLockResumer forwards the held outpoint and funding types 4 and 5. The remaining funded-wallet Finish success and PIN-cancellation flow is a reasonable, tracked deferral to the Maestro work in #1422.

romchornyi added a commit that referenced this pull request Nov 15, 2026
…rt Combine

Review round 1 on #1423:
- ADR-0040 (Proposed) records the fourth outcome, lockHeld, and the index
  and feature summary no longer promise that every failure after the money
  left finishes on its own.
- SendLockHeldViewModel imports Combine.
- LiveHeldAssetLockResumer takes its retry as a seam; a test checks it
  passes the held outpoint and funding type (4 and 5) to the retry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
SDD-Published-From: bfd878ad49301f452978fc68c12b47292148716c
@romchornyi

Copy link
Copy Markdown
Contributor Author

On the out-of-scope note about Core → Identity: it is already tracked in #1422. That route still reports a held lock as in progress because the SDK call returns no outpoint. The outpoint will come from dashpay/platform#5928 (a held-lock delivery state), and after that the route moves to lockHeld.

@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from d868dff to 5ce63da Compare November 15, 2026 17:25

@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 correctly implements the lockHeld outcome, carries the recorded lock through Finish, and documents the four-outcome external-send contract. Exact-head CI reports the simulator tests, accessibility audit, target-membership check, recovery check, workflow lint, and title validation passing; one internal contradiction remains in ADR-0040's decision paragraph.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

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: security-auditor); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial but contained change to external-send outcome handling, recovery orchestration, SwiftUI flow, localization, and tests, but it does not itself alter consensus, cryptography, key handling, storage migrations, or the underlying funds-movement implementation.
  • 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)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — 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 `docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md`:
- [SUGGESTION] docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md:35: Update the ADR decision statement to include lockHeld
  The revised ADR records `lockHeld` in the paragraph below, but the main Decision statement still says that the executor reports one of three outcomes and that any doubt is reported as `inFlight`. This makes the architecture record internally contradictory: a recorded held lock is now intentionally distinct from an unknown submitted result and offers Finish rather than the in-progress behavior. Rewrite this sentence to describe the four outcomes and distinguish `lockHeld` from `inFlight`.

@@ -29,6 +34,12 @@ later adds a fourth outcome for Shielded → Identity.

**Chosen:** option 1, the executor reports one of three outcomes and only `notSent` offers Retry; any doubt is reported as `inFlight`. Balances update with a delay after SPV or Platform sync, so a balance check could miss a payment that already left; the three outcomes follow the SDK's own no-retry contract.

@thepastaclaw thepastaclaw Nov 15, 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 75c8a203; see the replies below.

🟡 Suggestion: Update the ADR decision statement to include lockHeld

The revised ADR records lockHeld in the paragraph below, but the main Decision statement still says that the executor reports one of three outcomes and that any doubt is reported as inFlight. This makes the architecture record internally contradictory: a recorded held lock is now intentionally distinct from an unknown submitted result and offers Finish rather than the in-progress behavior. Rewrite this sentence to describe the four outcomes and distinguish lockHeld from inFlight.

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

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 75c8a20: the Decision statement now names the four outcomes and separates lockHeld (a recorded lock, Finish) from inFlight (submitted, outcome unknown).

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 75c8a203): The requested main Decision sentence now names all four outcomes and separates lockHeld from inFlight. A separate residual wording issue remains in the sentence's final “three outcomes” clause and is reported as a new documentation finding.

@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from 5ce63da to 75c8a20 Compare November 15, 2026 22:39

@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 implementation correctly adds the held-lock outcome and Finish flow, and the reported CI checks for tests, target membership, accessibility, workflow lint, recovery, and title validation succeeded. Two documentation comments remain stale: ADR-0040 still refers to three outcomes in its final clause, and SendOutcome's contract comment does not describe the lockHeld/Finish case.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

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: Update the SendOutcome contract comment for lockHeld
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:35-36

The type comment still describes only notSent and inFlight. The new lockHeld outcome is neither an in-progress unknown result nor a Retry case: it represents a recorded asset lock and offers Finish instead. Update the comment so callers and maintainers do not misclassify this payment state.

/// What happened to a send. Only `notSent` offers Retry and only `lockHeld` offers Finish; a submitted payment whose result is unknown is `inFlight` (ADR-0040).

source: muse-spark-1.3-contributor (phase1-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: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial, cross-cutting UI and send-flow change that alters recovery behavior for held asset locks and funds movement, but it does not itself change consensus, cryptography, key handling, or other critical-surface implementation criteria.
  • 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)
  • Code unchanged since the last final review (5ce63dab): 1 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 high); agent phase2-reviewer, gpt-6.1-sol — 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 `docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md`:
- [SUGGESTION] docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md:35: Fix the stale “three outcomes” clause in the revised Decision
  The revised Decision statement now correctly names four outcomes and distinguishes lockHeld from inFlight, but the final clause still says “the three outcomes follow the SDK's own no-retry contract.” This leaves the ADR internally contradictory. Change that clause to refer to all four outcomes.

## Decision outcome

**Chosen:** option 1, the executor reports one of three outcomes and only `notSent` offers Retry; any doubt is reported as `inFlight`. Balances update with a delay after SPV or Platform sync, so a balance check could miss a payment that already left; the three outcomes follow the SDK's own no-retry contract.
**Chosen:** option 1, extended by the revision below to four outcomes: the executor reports `sent`, `notSent`, `inFlight` or `lockHeld`, and only `notSent` offers Retry. A doubt about a submitted payment is reported as `inFlight`; a recorded asset lock whose Platform step did not finish is `lockHeld`, which offers Finish instead. Balances update with a delay after SPV or Platform sync, so a balance check could miss a payment that already left; the three outcomes follow the SDK's own no-retry contract.

@thepastaclaw thepastaclaw Nov 15, 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 8d747f92; see the replies below.

🟡 Suggestion: Fix the stale “three outcomes” clause in the revised Decision

The revised Decision statement now correctly names four outcomes and distinguishes lockHeld from inFlight, but the final clause still says “the three outcomes follow the SDK's own no-retry contract.” This leaves the ADR internally contradictory. Change that clause to refer to all four outcomes.

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

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 8d747f9: ADR-0040's revised Decision and the executor test contract comment now say four outcomes.

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 8d747f92): The closing clause of ADR-0040’s Decision now says four outcomes, consistent with the list at the start.

@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from 75c8a20 to dece9d2 Compare November 15, 2026 23:51
@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from dece9d2 to 462ca1a Compare November 16, 2026 00:16

@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 held-lock outcome is correctly modeled, routed through the existing authenticated recovery path, and covered by the reported passing unit, target-membership, and accessibility checks on the reviewed head. One documentation inconsistency remains in ADR-0040 and should be corrected for the decision record to match the four-outcome implementation.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Still open from earlier rounds (1)

  • 🟡 Suggestion: Fix the stale “three outcomes” clause in the revised Decision — docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md:35 (thread)
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: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial but contained change to external-send flow, asset-lock recovery UI, routing, localization, and tests; although it resumes funds movement, the diff does not alter consensus, cryptography, signing, key handling, or coin selection.
  • 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)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — 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 `docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md`:
- [SUGGESTION] docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md:35: Fix the stale “three outcomes” clause in the revised Decision
  (carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1423#discussion_r4580746639)

@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from 462ca1a to 998b237 Compare November 16, 2026 11:52
@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from 998b237 to ef21ed4 Compare November 16, 2026 12:19

@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 implementation correctly adds the recorded-lock outcome and authenticated resume path, with the relevant routing, SwiftUI flow, target membership, and seam coverage present. Two documentation comments remain stale: ADR-0040 still refers to three outcomes, and the executor test contract still says three outcomes. The simulator test check is still in progress; no failed code check is present in the supplied CI snapshot.

🟡 2 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Update the executor test contract comment to mention four outcomes
DashWalletTests/ExternalSend/ExternalSendExecutorTests.swift:25

This test suite now exercises .lockHeld, including executor mapping and held-lock routing, but its suite-level contract comment still says the executor has "one of three outcomes." Update the comment so it accurately describes the production contract covered by these tests.

/// the binding fee, broadcast only on `send`, one of four outcomes, one log line per outcome.

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

Still open from earlier rounds (1)

  • 🟡 Suggestion: Fix the stale “three outcomes” clause in the revised Decision — docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md:35 (thread)
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: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The change is large and intricate and modifies funds-movement recovery in ExternalSendExecutor, ShieldedTransferCoordinator, and AssetLockRecoveryService integration, including when a previously broadcast asset lock is resumed.
  • 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 — 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 `DashWalletTests/ExternalSend/ExternalSendExecutorTests.swift`:
- [SUGGESTION] DashWalletTests/ExternalSend/ExternalSendExecutorTests.swift:25: Update the executor test contract comment to mention four outcomes
  This test suite now exercises `.lockHeld`, including executor mapping and held-lock routing, but its suite-level contract comment still says the executor has "one of three outcomes." Update the comment so it accurately describes the production contract covered by these tests.

In `docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md`:
- [SUGGESTION] docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md:35: Fix the stale “three outcomes” clause in the revised Decision
  (carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1423#discussion_r4580746639)

@romchornyi

Copy link
Copy Markdown
Contributor Author

Round 7 (8d747f9): the holder can leave Finish during the proof wait; four outcomes in ADR-0040 and the executor test contract; develop's new addedToOwnShielded recovery outcome is shown on the lock-held screen. Finish keyed on a provably recoverable lock (and the Shielded Max path) waits for the SDK's LockHeld class, dashpay/platform#5928 → #1427.

@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

This revision lets users leave Finish during a proof wait and updates the ADR and executor test to describe four outcomes. A late recovery success can still change the flow’s screen after Close. Exact-head CI passed the simulator tests, target-membership, accessibility, workflow-lint, and recovery checks; this static review did not observe Finish on a funded wallet.

🔴 1 blocking | 🟡 2 suggestion(s)

Still open from earlier rounds (1)

  • 🔴 Blocking: Require evidence of a recoverable lock before offering Finish — DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:916-918 (thread)
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: Explain how to check the transfer when leaving Confirm early
DashWallet/Sources/UI/Payments/ExternalSend/Sending/SendOutcomeRouter.swift:61-62

runTwoStep enables Close while the Core funding call is pending. ConfirmViewModel.closeWhileWaitingForNetwork() immediately reports .inFlight, and confirm() then drops the actual outcome, so a later .lockHeld never reaches this new branch. The resulting toast says the send can take a few minutes to finish but gives no way to discover that the lock needs manual recovery. Keep Close available and preserve the warning not to send again, but tell users that the result is not yet known and that they can check the original transaction details.

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

🟡 Suggestion: Update the SendOutcome contract comment for four outcomes
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:35-39

The enum header still sends every error not proven to be pre-broadcast to .inFlight, contradicting the new .lockHeld case and its Finish action. The .inFlight case comment also promises that sync will settle it, although that case is used when the outcome is unknown. Document which action each outcome permits without promising automatic completion.

/// What happened to a send. Only `notSent` offers Retry and only `lockHeld` offers Finish (ADR-0040).
enum SendOutcome {
    case sent
    /// The outcome is unknown; offers neither Retry nor Finish.

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

Review provenance

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

  • Triage: normal by gpt-6.2-sol (effort low) — The change adds a send outcome and an asynchronous recovery flow, but it delegates funds movement to the existing recovery service without changing how transactions are built, signed, or 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 (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Code unchanged since the last final review (c82ec02a): 2 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — 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/Payments/ExternalSend/Sending/SendLockHeldViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Sending/SendLockHeldViewModel.swift:126-128: Do not present unverified lock consumption as confirmed
  `AssetLockRecoveryService` can return `.completionUnconfirmed` from an advisory already-consumed report, without verified consumption. The lock can remain nonterminal, and the advisory record excludes it from bulk recovery while transaction details still allows an explicit recheck. Closing the new sheet with “Already spent — nothing to transfer” tells the user to stop looking even though the transfer may still need attention. Say that completion could not be verified and point the user to the original transaction details without suggesting a new payment.

In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:424-425: Ignore late Finish results before changing the closed flow’s screen
  A successful resume after Close sets the published `step` to `.sent` before `finish()` reaches its `isEnded` guard. No second finish event is emitted, but the step change still drives the sheet’s presentation binding while the host may be dismissing. Guard before changing `step`, and extend the close-during-Finish test to assert that the late completion leaves the step unchanged, not just that it emits no second event.

In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:916-918: Require evidence of a recoverable lock before offering Finish
  (carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1423#discussion_r4618784253)

Comment on lines +126 to +128
case .completionUnconfirmed:
return .info(NSLocalizedString(
"Already spent — nothing to transfer", comment: "Asset-lock retry found the lock already consumed"))

@thepastaclaw thepastaclaw Nov 19, 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 e0d58356; see the replies below.

🟡 Suggestion: Do not present unverified lock consumption as confirmed

AssetLockRecoveryService can return .completionUnconfirmed from an advisory already-consumed report, without verified consumption. The lock can remain nonterminal, and the advisory record excludes it from bulk recovery while transaction details still allows an explicit recheck. Closing the new sheet with “Already spent — nothing to transfer” tells the user to stop looking even though the transfer may still need attention. Say that completion could not be verified and point the user to the original transaction details without suggesting a new payment.

source: gpt-6.2-sol (phase2-reviewer: 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 52f1d5e: .completionUnconfirmed no longer claims the lock was spent. It reads "Couldn't confirm the transfer finished. Check it in the original transaction's details." (new key in all 43 locales); the test pins the text.

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 e0d58356): Your revised copy is present in all 43 main-app catalogs. The ViewModel test verifies that .completionUnconfirmed points to the original transaction without claiming the lock was spent.

Comment on lines +424 to +425
private func finishedLockHeld(_ result: SendLockHeldViewModel.Result) {
switch result {

@thepastaclaw thepastaclaw Nov 19, 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 b0ff0ad0; see the replies below.

🟡 Suggestion: Ignore late Finish results before changing the closed flow’s screen

A successful resume after Close sets the published step to .sent before finish() reaches its isEnded guard. No second finish event is emitted, but the step change still drives the sheet’s presentation binding while the host may be dismissing. Guard before changing step, and extend the close-during-Finish test to assert that the late completion leaves the step unchanged, not just that it emits no second event.

Suggested change
private func finishedLockHeld(_ result: SendLockHeldViewModel.Result) {
switch result {
private func finishedLockHeld(_ result: SendLockHeldViewModel.Result) {
guard !isEnded else { return }
switch result {

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

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 b0ff0ad0): Your isEnded guard now runs before the result switch, so a late completion cannot move a closed flow to .sent.

@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: 1 blocker

  • Require evidence of a recoverable lock before offering Finish — DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:956-958 (thread, carried)
    Impact: A user who confirms a non-Max Core-to-Shielded send whose recipient record fails to save is told their Dash is held and offered Finish, even though the SDK abandoned the lock before broadcast.

New on this head: This revision uses the shared scroll layout for the held-lock sheet and ignores Finish results that arrive after the send flow closes. At the reviewed head, the simulator suite, test-target membership check, workflow lint, recovery check, and accessibility audit passed; the review check was pending.

🔴 1 blocking | 🟡 2 suggestion(s)

Still open from earlier rounds (2)

  • 🔴 Blocking: Require evidence of a recoverable lock before offering Finish — DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:956-958 (thread)
  • 🟡 Suggestion: Do not present unverified lock consumption as confirmed — DashWallet/Sources/UI/Payments/ExternalSend/Sending/SendLockHeldViewModel.swift:126-128 (thread)
Review provenance

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

  • Triage: normal by gpt-6.2-sol (effort low) — The diff adds a recovery outcome and a user-triggered SwiftUI flow that reuses the existing authenticated retry service without changing how funds are moved.
  • Phase 1 reviewers: not run (skipped for throughput: 15 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — 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/Payments/ExternalSend/Sending/SendLockHeldSheet.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Sending/SendLockHeldSheet.swift:33: The Finish sheet's scroll area extends below the sheet at its height cap
  Impact: When large text or a short screen pushes the Finish sheet to its height cap, the bottom of the scroll area extends past the visible body even at the end of scrolling.
  The scroll view calculates its end position for a taller viewport than the capped sheet provides. This revision switches to `CappedSheetBody`, which subtracts 72 points from the cap (`ConfirmSheet.swift:175–192`). The pinned DashUIKit `BottomSheet` puts an 18-point grabber and a navigation bar at least 74 points high above the body, leaving at least 20 points less room than the helper assumes. The body's 20-point bottom padding can absorb the nominal difference, so this does not establish that Close is unreachable. Size the viewport from the actual space below the header, or derive its cap from the same header and detent sizing inputs as DashUIKit.

In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:956-958: Require evidence of a recoverable lock before offering Finish
  (carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1423#discussion_r4618784253)

In `DashWallet/Sources/UI/Payments/ExternalSend/Sending/SendLockHeldViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Sending/SendLockHeldViewModel.swift:126-128: Do not present unverified lock consumption as confirmed
  (carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1423#discussion_r4623377934)

showBackButton: .constant(false),
showsCloseButton: false,
onClose: onClose,
content: { CappedSheetBody { sheetBody } })

@thepastaclaw thepastaclaw Nov 23, 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 e0d58356; see the replies below.

🟡 Suggestion: The Finish sheet's scroll area extends below the sheet at its height cap
Impact: When large text or a short screen pushes the Finish sheet to its height cap, the bottom of the scroll area extends past the visible body even at the end of scrolling.

The scroll view calculates its end position for a taller viewport than the capped sheet provides. This revision switches to CappedSheetBody, which subtracts 72 points from the cap (ConfirmSheet.swift:175–192). The pinned DashUIKit BottomSheet puts an 18-point grabber and a navigation bar at least 74 points high above the body, leaving at least 20 points less room than the helper assumes. The body's 20-point bottom padding can absorb the nominal difference, so this does not establish that Close is unreachable. Size the viewport from the actual space below the header, or derive its cap from the same header and detent sizing inputs as DashUIKit.

source: gpt-6.2-sol (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 f26fdf5 (#1409): CappedSheetBody sizes its viewport from the space below the header (grabber + titled bar, headerHeight = 18 + 74 pt), one fix for every capped sheet. Applied at Confirm, Send-failed and this held-lock sheet, which all use CappedSheetBody.

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 e0d58356): Your shared sizing fix is present on this head: the Finish sheet uses CappedSheetBody, which subtracts the 18-point grabber and 74-point titled bar before sizing the scroll viewport, including Close.

Comment on lines +424 to +425
private func finishedLockHeld(_ result: SendLockHeldViewModel.Result) {
switch result {

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 b0ff0ad0): Your isEnded guard now runs before the result switch, so a late completion cannot move a closed flow to .sent.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Moving to draft: Finish keys on the SDK's verdict that a held lock is recoverable, which dashpay/platform#5928 adds (#1427). Without it the held-lock outcome would map back to .inFlight and nothing in this PR would be reachable. #1406, #1407 and #1409 go without this layer. Round 9 fixes are on the branch (52f1d5e): the .completionUnconfirmed text and the shared sheet height.

@romchornyi
romchornyi marked this pull request as draft November 24, 2026 09:25
@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from 52f1d5e to e0d5835 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 52f1d5e → e0d5835. 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: 1 blocker

  • Require evidence of a recoverable lock before offering Finish — DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:953-973 (thread, carried)
    Impact: A user confirming an exact-amount Core → Shielded send can be told their Dash is held and offered Finish when a local storage failure stopped the asset lock before broadcast.

New on this head: The rebase narrows Finish to Core → Shielded sends, fixes the sheet’s scroll height at its cap, and directs users to the original transaction when completion cannot be confirmed. The held-lock tests passed on this head; the simulator suite’s only failure was the same unchanged scanner-prefetch assertion that also failed on the stacked base.

🔴 1 blocking

Still open from earlier rounds (1)

  • 🔴 Blocking: Require evidence of a recoverable lock before offering Finish — DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:953-973 (thread)
Review provenance

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

  • Triage: normal by gpt-6.2-sol (effort low) — The diff adds a send outcome and an interactive recovery flow, but delegates funds movement to the existing authenticated retry service without changing transaction construction or spending rules.
  • 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)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — 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/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:953-973: Require evidence of a recoverable lock before offering Finish
  (carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1423#discussion_r4618784253)
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.

  • Scanner-prefetch test depends on the app’s selected network — testTheScannerPrefetchesOnlyARequestTheSendHonors uses a testnet address at ExternalSendFlowTests.swift:600, but prefetch validation reads WalletEnvironment.networkKind, which defaults to mainnet. The assertion failed on both the exact head (run 45464906780) and the stacked base (run 45464900749); this PR does not change the assertion, fixture, or parser.
    • Follow-up: Fix the test on the stacked Send screens branch by making its network and address fixture agree without depending on persisted app state.

Comment on lines +908 to +918
static func result(
phase: ShieldedTransferCoordinator.Phase, lastFailure: Error?, lockKept: Bool
phase: ShieldedTransferCoordinator.Phase, lastFailure: Error?, heldLock: HeldAssetLock?
) -> CoreTwoStepResult {
switch phase {
case .success:
return .completed
case .submittedUnconfirmed:
return .unconfirmed
default:
return .failed(lastFailure ?? UnfinishedTransfer(), assetLockRecorded: lockKept)
if let heldLock { return .lockHeld(heldLock) }
return .failed(lastFailure ?? UnfinishedTransfer(), assetLockRecorded: false)

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.

Still applies (re-reviewed at e0d58356): Agreed that disabling the only Finish producer would make the feature unreachable; waiting in draft avoids shipping that version. The rebase removes the type-4 producer, but the type-5 persistence failure still reaches Finish on this head, so this stays open until the PR reads the SDK verdict.

Comment on lines +126 to +128
case .completionUnconfirmed:
return .info(NSLocalizedString(
"Already spent — nothing to transfer", comment: "Asset-lock retry found the lock already consumed"))

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 e0d58356): Your revised copy is present in all 43 main-app catalogs. The ViewModel test verifies that .completionUnconfirmed points to the original transaction without claiming the lock was spent.

showBackButton: .constant(false),
showsCloseButton: false,
onClose: onClose,
content: { CappedSheetBody { sheetBody } })

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 e0d58356): Your shared sizing fix is present on this head: the Finish sheet uses CappedSheetBody, which subtracts the 18-point grabber and 74-point titled bar before sizing the scroll viewport, including Close.

@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from e0d5835 to 4f23f5c Compare November 25, 2026 13:09
@romchornyi
romchornyi changed the base branch from feat/external-send-screens to feat/external-send-platform-identity November 25, 2026 13:09
@romchornyi

Copy link
Copy Markdown
Contributor Author

Round 10: the held-lock sheet (SendLockHeldSheet) uses the same CappedSheetBody fix as #1409 (65e1193): the bound follows the presented sheet's visible area, not 95% of the window. This PR now sits on #1502 (Platform → someone else's identity), and #1501 (credit-send History) sits on it. It stays a draft for dashpay/platform#5928.

A Core to Shielded send whose Platform step failed
after the asset lock was broadcast and recorded was reported as
inFlight, with the "It will finish on its own" Toast, but nothing
finished it: only Rebroadcast in the transaction details resumes the
lock.

The executor now reports such a send as lockHeld, carrying the lock's
outpoint and funding type. It opens its own sheet: "Your Dash is held
for this transfer. Finish it now, or later from the transaction
details." Finish runs the same resume as Rebroadcast
(AssetLockRecoveryService.retry, which asks for the PIN); Close leaves
the lock for the transaction details. inFlight keeps meaning submitted
with an unknown result. A Core to Identity send still reports inFlight:
its top-up call returns no outpoint to resume.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
SDD-Published-From: 2e78910ed28abdc6a8338da34812f0fedb71bf3e
@romchornyi
romchornyi force-pushed the feat/external-send-lock-held branch from 4adde32 to 888305c 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.

External send: an asset lock whose Platform step did not run is reported as "in progress, it will finish on its own", but nothing finishes it

2 participants