Skip to content

feat(wallet): domain model for sending to any destination - #1406

Open
romchornyi wants to merge 1 commit into
developfrom
feat/external-send-domain
Open

romchornyi wants to merge 1 commit into
developfrom
feat/external-send-domain

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

First part of the new external Send for MO-1121 (Android parity: dash-wallet#1680): pay from every balance (Core, Shielded, Platform, Identity) to every destination type (Core address, Shielded address, Platform address, Identity ID). This PR adds only the domain model, so it can be reviewed without any UI or money movement.

What was done?

  • Destination and DestinationParser: the destination type from typed, pasted, scanned or linked text (Core, Platform and Shielded addresses, Identity IDs, dash: links with an amount), network checks, and a length bound before Base58/Bech32m decoding.
  • SendPairPolicy: one pure rule set for every source × destination pair — the route, or the reason the pair is unavailable — plus the Confirm warnings. [ADR-0038] (added in feat(wallet): new Send screens and entry points #1409)
  • AmountRules: Max, the DashPay reserve on Identity, the balance check.
  • SendOutcome: every send ends as sent, not sent (with Retry) or in progress (no Retry); the mapping from the existing send errors. [ADR-0040] (added in feat(wallet): new Send screens and entry points #1409)
  • ScriptAddressCodec / PaymentNetworkResolver / DWParsedPaymentURI: the address decoding helpers the parser shares with the existing Send; SendScreen now takes its warning texts from the shared SendWarningText.
  • WalletSendService: ErrorCode and errorDomain readable outside the file so the outcome mapping can name existing send errors.

Nothing calls the new types from a screen yet; the services come in #1407 and the screens in #1409. Code comments cite ADRs whose public copies are added in #1409.

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

How Has This Been Tested?

dashwallet-dashpay, Debug, iPhone 17 simulator (iOS 26.5): 2374 tests, 0 failures, 1 skipped.

  • DestinationParserTests, SendPairPolicyTests, AmountRulesTests, SendOutcomeMappingTests, the Bech32m URI case in PaymentProtocolTests
  • Test-target membership, scripts/a11y_audit.py --check, and a second build leaves the catalogs unchanged

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 assigned this pull request to a milestone

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3425e3b-9f86-44f5-88ad-87a505e97920
Commits

Reviewing files that changed from the base of the PR and between a00541e and 3d7d56a.

Files selected for processing: 73

  • DashWallet.xcodeproj/project.pbxproj
  • DashWallet/Sources/Infrastructure/SwiftDashSDK/PaymentNetworkResolver.swift
  • DashWallet/Sources/Models/PaymentProtocol/ScriptAddressCodec.swift
  • DashWallet/Sources/Models/Transactions/WalletSendService.swift
  • DashWallet/Sources/UI/Payments/ExternalSend/Domain/AmountRules.swift
  • DashWallet/Sources/UI/Payments/ExternalSend/Domain/ConfirmWarning.swift
  • DashWallet/Sources/UI/Payments/ExternalSend/Domain/Destination.swift
  • DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift
  • DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift
  • DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendPairPolicy.swift
  • DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendRoute.swift
  • DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendSource.swift
  • DashWallet/Sources/UI/Payments/Pay/SendScreen.swift
  • DashWallet/Sources/UI/Payments/PaymentModels/DWParsedPaymentURI.swift
  • DashWallet/ar.lproj/Localizable.strings
  • DashWallet/bg.lproj/Localizable.strings
  • DashWallet/ca.lproj/Localizable.strings
  • DashWallet/cs.lproj/Localizable.strings
  • DashWallet/da.lproj/Localizable.strings
  • DashWallet/de.lproj/Localizable.strings
  • DashWallet/el.lproj/Localizable.strings
  • DashWallet/en.lproj/Localizable.strings
  • DashWallet/eo.lproj/Localizable.strings
  • DashWallet/es.lproj/Localizable.strings
  • DashWallet/et.lproj/Localizable.strings
  • DashWallet/fa.lproj/Localizable.strings
  • DashWallet/fi.lproj/Localizable.strings
  • DashWallet/fil.lproj/Localizable.strings
  • DashWallet/fr.lproj/Localizable.strings
  • DashWallet/hr.lproj/Localizable.strings
  • DashWallet/hu.lproj/Localizable.strings
  • DashWallet/id.lproj/Localizable.strings
  • DashWallet/it.lproj/Localizable.strings
  • DashWallet/ja.lproj/Localizable.strings
  • DashWallet/ko.lproj/Localizable.strings
  • DashWallet/mk.lproj/Localizable.strings
  • DashWallet/ms.lproj/Localizable.strings
  • DashWallet/nb.lproj/Localizable.strings
  • DashWallet/nl.lproj/Localizable.strings
  • DashWallet/pl.lproj/Localizable.strings
  • DashWallet/pt.lproj/Localizable.strings
  • DashWallet/ro.lproj/Localizable.strings
  • DashWallet/ru.lproj/Localizable.strings
  • DashWallet/sk.lproj/Localizable.strings
  • DashWallet/sl.lproj/Localizable.strings
  • DashWallet/sl_SI.lproj/Localizable.strings
  • DashWallet/sq.lproj/Localizable.strings
  • DashWallet/sr.lproj/Localizable.strings
  • DashWallet/sv.lproj/Localizable.strings
  • DashWallet/th.lproj/Localizable.strings
  • DashWallet/tr.lproj/Localizable.strings
  • DashWallet/uk.lproj/Localizable.strings
  • DashWallet/vi.lproj/Localizable.strings
  • DashWallet/zh-Hans.lproj/Localizable.strings
  • DashWallet/zh-Hant-TW.lproj/Localizable.strings
  • DashWallet/zh.lproj/Localizable.strings
  • DashWallet/zh_TW.lproj/Localizable.strings
  • DashWalletTests/ExternalSend/AmountRulesTests.swift
  • DashWalletTests/ExternalSend/DestinationParserTests.swift
  • DashWalletTests/ExternalSend/SendOutcomeMappingTests.swift
  • DashWalletTests/ExternalSend/SendPairPolicyTests.swift
  • DashWalletTests/PaymentProtocolTests.swift
  • docs/adr/0036-ship-the-ios-screens-and-the-sdk-binding-as-two-surfaces.md
  • docs/adr/0037-build-external-send-as-a-new-module-over-the-existing-spend-seams.md
  • docs/adr/0038-decide-every-source-and-destination-pair-in-one-policy.md
  • docs/adr/0039-estimate-the-fee-on-send-and-recompute-it-on-confirm.md
  • docs/adr/0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md
  • docs/adr/0041-keep-identity-to-shielded-off-in-this-release.md
  • docs/adr/0042-report-moved-to-platform-when-a-shielded-to-identity-top-up-fails-after-the-unshield.md
  • docs/adr/0043-bind-the-fee-where-the-sdk-can-and-mark-the-rest-as-an-estimate.md
  • docs/adr/0044-top-up-an-identity-from-shielded-in-one-step.md
  • docs/adr/0045-add-an-external-identity-top-up-and-a-non-blocking-identity-read-to-the-sdk.md
  • docs/adr/README.md
  • 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

@thepastaclaw

thepastaclaw commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Final review complete — no blockers (commit 3d7d56a) · triage: normal

@romchornyi romchornyi changed the title feat(external-send): domain model for sending to any destination feat(wallet): domain model for sending to any destination 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 three confirmed blocking issues: active localization keys are removed, SendSource does not compile with its new Set usage, and malformed Unicode input can crash the Bech32 decoder. Additional suggestions cover unbounded URI parsing, incomplete pre-broadcast outcome mapping, and unresolved or incorrect ADR references. The available CI snapshot has no failed code check; title validation failed as a policy check, while other checks remain queued.

🔴 3 blocking | 🟡 4 suggestion(s)

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

🔴 Blocking: Restore localization keys still used by the application
DashWallet/en.lproj/Localizable.strings:307-311

This catalog cleanup removes keys that remain in active source, and the same deletions appear across the localized catalogs. Confirmed live lookups include "The wallet could not check your DashPay username. Open the link again." in PlatformDashConnectDataSource.swift, "The details of this connection could not be read." in ConnectionSheet.swift, "No biometric spending limit is set" in AdvancedSecurityViewModel.swift, and "You need at least %@ Dash to create this username" in CreateUsernameViewModel.swift. Removing these entries causes every non-English locale to fall back to the key/English default for those screens. Restore the entries or remove/update every corresponding lookup.

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

🔴 Blocking: Declare SendSource as Hashable
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendSource.swift:21

The new tests construct Set(SendSource.allCases), and SendPairPolicy compares SendSource values. SendSource only declares CaseIterable, so the required Hashable and Equatable conformances are not synthesized and the app/test targets cannot compile.

enum SendSource: CaseIterable, Hashable {

source: fresh:general

🔴 Blocking: Reject non-ASCII input before invoking Bech32m.decode
DashWallet/Sources/UI/Payments/PaymentModels/DWParsedPaymentURI.swift:56

DashAddressClassifier forwards arbitrary input directly to the SDK decoder. For a malformed value such as "é1qqqqqq", the decoder reaches checksum verification with a non-ASCII HRP; its hrpExpand implementation force-unwraps char.asciiValue, so the pasted or scanned destination crashes the process instead of returning nil. Guard the input to the decoder to ASCII before calling it.

guard text.utf8.allSatisfy({ $0 < 128 }),
      text.utf8.count <= maxBech32mLength,
      let decoded = decode(text.lowercased()) else { return nil }

source: fresh:general

🟡 Suggestion: Bound raw URI and clipboard input before parsing
DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift:37-43

The parser bounds Base58 and Bech32m destinations, but a colon-bearing input is passed to BIP70URI without a raw-size limit. BIP70URI splits and percent-decodes every query pair, so a large dash:?r=...&x=... payload can cause substantial temporary allocations. find(in:) also materializes all whitespace-separated words before any candidate is parsed. Apply a documented input bound before constructing BIP70URI and before components(separatedBy:) so untrusted pasteboard, deep-link, and scan input cannot bypass the parser's existing decoder limits.

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

🟡 Suggestion: Map known pre-broadcast failures to notSent
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:42-51

Only BIP70Error.expired is classified explicitly, so failures such as badURL, malformedRequest, networkMismatch, untrustedCertificate, nonStandardScript, missingPaymentURL, and walletNotReady fall through to the NSError mapping and become inFlight. The same happens to WalletSendService's initialRestoreSync error through the default ErrorCode branch at lines 141-150, even though that gate throws before authentication, input selection, signing, or broadcast. Once the next service layer routes these failures through SendOutcome, users will see an in-progress state for sends that never left the device. Map errors proven to occur before build/lock/signing to notSent while retaining inFlight for post-handover and ambiguous failures.

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

🟡 Suggestion: Record or remove the unresolved external-send ADR references
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendPairPolicy.swift:79

The new policy cites ADR-0038 and ADR-0041, while SendOutcome cites ADR-0040 and SendRoute cites ADR-0041, but none of those records exists in docs/adr at this head; the index ends at ADR-0033. The stack description says the public copies will arrive in #1409, but merging this standalone layer leaves dangling references and places significant decisions outside the PR that introduces them. Add the proposed ADRs and index entries here, or remove the references until the decisions are recorded in this PR.

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

🟡 Suggestion: Remove the unrelated ADR-0009 citation
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendRoute.swift:52-53

The isFeeExact documentation cites ADR-0009, but docs/adr/0009 records the App Connect login decision and does not describe fee exactness or external-send routing. This sends maintainers to an unrelated decision record. Remove the citation or replace it with the decision record that actually governs this fee behavior.

/// Whether the fee prepared at Continue is the fee the send pays. Only Core → Core, which also carries
/// BIP70 payment requests, is built and signed at Continue; every other route's fee is an estimate.

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); 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 domain-logic change spanning destination parsing, network validation, send-pair routing, amount rules, outcome mapping, and shared payment helpers, but it does not itself implement funds movement, cryptography, key handling, or another critical surface.
  • 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 — 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 `DashWallet/en.lproj/Localizable.strings`:
- [BLOCKING] DashWallet/en.lproj/Localizable.strings:307-311: Restore localization keys still used by the application
  This catalog cleanup removes keys that remain in active source, and the same deletions appear across the localized catalogs. Confirmed live lookups include "The wallet could not check your DashPay username. Open the link again." in PlatformDashConnectDataSource.swift, "The details of this connection could not be read." in ConnectionSheet.swift, "No biometric spending limit is set" in AdvancedSecurityViewModel.swift, and "You need at least %@ Dash to create this username" in CreateUsernameViewModel.swift. Removing these entries causes every non-English locale to fall back to the key/English default for those screens. Restore the entries or remove/update every corresponding lookup.

In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendSource.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendSource.swift:21: Declare SendSource as Hashable
  The new tests construct Set(SendSource.allCases), and SendPairPolicy compares SendSource values. SendSource only declares CaseIterable, so the required Hashable and Equatable conformances are not synthesized and the app/test targets cannot compile.

In `DashWallet/Sources/UI/Payments/PaymentModels/DWParsedPaymentURI.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/PaymentModels/DWParsedPaymentURI.swift:56: Reject non-ASCII input before invoking Bech32m.decode
  DashAddressClassifier forwards arbitrary input directly to the SDK decoder. For a malformed value such as "é1qqqqqq", the decoder reaches checksum verification with a non-ASCII HRP; its hrpExpand implementation force-unwraps char.asciiValue, so the pasted or scanned destination crashes the process instead of returning nil. Guard the input to the decoder to ASCII before calling it.

In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift:37-43: Bound raw URI and clipboard input before parsing
  The parser bounds Base58 and Bech32m destinations, but a colon-bearing input is passed to BIP70URI without a raw-size limit. BIP70URI splits and percent-decodes every query pair, so a large dash:?r=...&x=... payload can cause substantial temporary allocations. find(in:) also materializes all whitespace-separated words before any candidate is parsed. Apply a documented input bound before constructing BIP70URI and before components(separatedBy:) so untrusted pasteboard, deep-link, and scan input cannot bypass the parser's existing decoder limits.

In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:42-51: Map known pre-broadcast failures to notSent
  Only BIP70Error.expired is classified explicitly, so failures such as badURL, malformedRequest, networkMismatch, untrustedCertificate, nonStandardScript, missingPaymentURL, and walletNotReady fall through to the NSError mapping and become inFlight. The same happens to WalletSendService's initialRestoreSync error through the default ErrorCode branch at lines 141-150, even though that gate throws before authentication, input selection, signing, or broadcast. Once the next service layer routes these failures through SendOutcome, users will see an in-progress state for sends that never left the device. Map errors proven to occur before build/lock/signing to notSent while retaining inFlight for post-handover and ambiguous failures.

In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendPairPolicy.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendPairPolicy.swift:79: Record or remove the unresolved external-send ADR references
  The new policy cites ADR-0038 and ADR-0041, while SendOutcome cites ADR-0040 and SendRoute cites ADR-0041, but none of those records exists in docs/adr at this head; the index ends at ADR-0033. The stack description says the public copies will arrive in #1409, but merging this standalone layer leaves dangling references and places significant decisions outside the PR that introduces them. Add the proposed ADRs and index entries here, or remove the references until the decisions are recorded in this PR.

In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendRoute.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendRoute.swift:52-53: Remove the unrelated ADR-0009 citation
  The isFeeExact documentation cites ADR-0009, but docs/adr/0009 records the App Connect login decision and does not describe fee exactness or external-send routing. This sends maintainers to an unrelated decision record. Remove the citation or replace it with the decision record that actually governs this fee behavior.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Answers to the review of 209dff05b (findings not shown inline). Fixes are in 8050bc4; the branch is now on develop d3a0f85.

  • Restore localization keys still used by the application — not an issue in this PR: those deletions were chore(ui): drop unused keys and sort Localizable.strings as BartyCrouch writes them #1405's (the branch sat on its parent). Rebased on develop, the PR now only adds keys; every key it looks up is in the catalogs, and a BartyCrouch run on the stack changes nothing.
  • Declare SendSource as Hashable — not changing: SendSource has no associated values, so Swift synthesizes Equatable and Hashable.
  • Reject non-ASCII input before invoking Bech32m.decode — fixed: decodeBech32m refuses text that is not ASCII before the SDK decoder (testANonASCIIBech32mTextIsRefusedWithoutReachingTheDecoder).
  • Bound raw URI and clipboard input before parsing — not changing: the parse splits and percent-decodes once and parses each word once, so the work is linear in the input; nothing repeats over it like the Base58 case the existing bound protects.
  • Map known pre-broadcast failures to notSent — not changing: those errors are thrown while fetching, verifying and building at Continue and go through the executor's preparationError, never through SendOutcome(error:); .expired is already not sent.
  • Record or remove the unresolved external-send ADR references — fixed: the feature's ADRs (0036–0045) now come with this PR.
  • Remove the unrelated ADR-0009 citation — fixed: the fee decision is ADR-0043.

@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

Updated after discussion: 2 finding(s) of this review were settled in the inline threads; no blocking finding remains.

  • ✅ Withdrawn: 🔴 Declare SendSource as Hashable
  • ✅ Withdrawn: 🔴 Declare AddressForm Equatable before comparing forms

The reviewed head still contains two compile-time conformance errors in the new domain model, plus a zero-amount validation defect that can allow an invalid send to pass the domain check. The simulator test check remains in progress; no completed code check failure is available in the supplied CI snapshot.

🔴 2 0 blocking

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: Reject zero amounts in AmountRules.check
DashWallet/Sources/UI/Payments/ExternalSend/Domain/AmountRules.swift:49-51

The check accepts amount == 0 whenever balance covers the fee, returning .ok for every funded source. This domain method is described as deciding whether a typed amount can be sent, and the existing send boundary rejects zero amounts, so allowing zero here can enable Continue for an invalid zero-value payment before the later executor rejects it. Add an explicit positive-amount guard before the spendable-balance check.

guard amount > 0,
      let spendable = spendable(balance: balance, fee: fee),
      amount <= spendable else {
    return .notEnough
}

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); 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 domain-logic change spanning destination parsing, network validation, send-pair routing, amount rules, outcome mapping, localization, and test-target integration, but the diff itself does not implement funds movement, signing, coin selection, cryptography, key handling, or storage migration.
  • 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 (209dff05): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed, 1 not confirmed (now follow-up candidates)
  • 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
🤖 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/Domain/SendSource.swift`:
- [BLOCKING → WITHDRAWN in discussion; do not fix] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendSource.swift:21: Declare SendSource as Hashable
  The enum still declares only CaseIterable, but SendPairPolicy compares SendSource values and the new tests construct Set<SendSource>. A value-less enum does not acquire the required Hashable conformance merely from having no associated values, so the dashpay target cannot compile these uses until the conformance is declared explicitly.

In `DashWallet/Sources/Models/PaymentProtocol/ScriptAddressCodec.swift`:
- [BLOCKING → WITHDRAWN in discussion; do not fix] DashWallet/Sources/Models/PaymentProtocol/ScriptAddressCodec.swift:61-64: Declare AddressForm Equatable before comparing forms
  DestinationParser compares the result of addressForm(forVersion:) with .scriptHash at line 99, but AddressForm has no Equatable conformance. The comparison therefore has no applicable == overload and prevents the destination parser from compiling.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: The dashpay target compiles DestinationParser.swift, whose `address` method evaluates `form == .scriptHash`, but AddressForm does not conform to Equatable. Swift has no applicable `==` overload for that enum, so the target fails to compile._

import Foundation

/// Where an external send takes its funds from.
enum SendSource: CaseIterable {

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

✅ Withdrawn at 8050bc47; see the replies below.

🔴 Blocking: Declare SendSource as Hashable

The enum still declares only CaseIterable, but SendPairPolicy compares SendSource values and the new tests construct Set. A value-less enum does not acquire the required Hashable conformance merely from having no associated values, so the dashpay target cannot compile these uses until the conformance is declared explicitly.

Suggested change
enum SendSource: CaseIterable {
enum SendSource: CaseIterable, Hashable {

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.

Not changing this: an enum without associated values gets Equatable and Hashable synthesized, so SendSource already conforms; the target compiles and DashWalletTests on simulator pass on this head (8050bc4), including the tests that build Set<SendSource>.

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.

I checked the current checkout: SendSource declares only CaseIterable, and there is no separate Hashable extension. Swift can synthesize Hashable for this enum only after the conformance is declared; having no associated values does not implicitly make the type conform. The Set(SendSource.allCases) test therefore still requires SendSource: Hashable, regardless of the reported simulator result.

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.

Per the Swift standard library documentation for Hashable: "For an enum, all its associated values must conform to Hashable. (An enum without associated values has Hashable conformance even without the declaration.)" SendSource has no associated values, so it is Hashable without the declaration; the dashpay target compiles Set(SendSource.allCases) and DashWalletTests pass on this head. Leaving this to a maintainer.

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.

You’re right; my earlier finding was incorrect. Swift automatically provides Equatable and Hashable for enums without associated values, so SendSource is valid in Set<SendSource> without an explicit declaration. The successful CI result is consistent with that behavior.

Withdrawing this finding.

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.

Withdrawn (re-reviewed at 8050bc47): This is not a compile defect on the reviewed head: SendSource has no associated values, so it has the required Hashable behavior without an explicit declaration, and the successful simulator test check covers Set usage.

Comment on lines +61 to +64
enum AddressForm {
case pubkeyHash
case scriptHash
}

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

✅ Withdrawn at 8050bc47; see the replies below.

🔴 Blocking: Declare AddressForm Equatable before comparing forms

DestinationParser compares the result of addressForm(forVersion:) with .scriptHash at line 99, but AddressForm has no Equatable conformance. The comparison therefore has no applicable == overload and prevents the destination parser from compiling.

Raised on code unchanged since the last review, and confirmed by an independent pass: The dashpay target compiles DestinationParser.swift, whose address method evaluates form == .scriptHash, but AddressForm does not conform to Equatable. Swift has no applicable == overload for that enum, so the target fails to compile.

Suggested change
enum AddressForm {
case pubkeyHash
case scriptHash
}
enum AddressForm: Equatable {

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.

Not changing this: AddressForm has no associated values, so Equatable is synthesized and form == .scriptHash compiles; DashWalletTests on simulator pass on this head (8050bc4).

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.

I checked the current checkout: AddressForm declares neither Equatable nor an equality operator, and there is no separate conformance extension. Swift synthesizes Equatable only when the type explicitly declares that conformance; an enum with no associated values does not implicitly conform. The form == .scriptHash expression therefore still needs AddressForm: Equatable, notwithstanding the reported simulator result.

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.

Per the Swift standard library documentation for Equatable: "(An enum without associated values has Equatable conformance even without the declaration.)" AddressForm has no associated values, so form == .scriptHash compiles; DashWalletTests pass on this head. Leaving this to a maintainer.

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.

You’re right; my earlier finding was incorrect. Swift automatically provides Equatable for enums without associated values, so form == .scriptHash is valid without an explicit declaration on AddressForm. The successful CI result confirms the parser compiles as written.

Withdrawing this finding.

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.

Withdrawn (re-reviewed at 8050bc47): This is not a compile defect on the reviewed head: AddressForm has no associated values, so the Swift toolchain synthesizes the required Equatable behavior, and the successful simulator test check confirms the comparison compiles.

@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 after discussion — commit 8050bc4

Standing review was CHANGES_REQUESTED; this re-review is COMMENT: no blocking findings remain.

Not approved yet: on a later review round an approval needs the fresh Phase-2 audit of the whole change, which the review of this commit skipped because it had found a blocker. That audit is queued for this commit and approves if it finds nothing.

No longer blocking:

  • Declare SendSource as Hashable
  • Declare AddressForm Equatable before comparing forms

Same commit as the standing review; the inline threads above carry the per-finding outcome. This follow-up exists only to correct the verdict.

Review provenance

Source: conversation lane gpt-6.1-sol (agent: conversation); no reviewer or verifier lanes ran for this follow-up

  • Verdict moved because the inline discussion withdrew or deferred findings of the standing review of this commit; the code was not re-reviewed

@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 after discussion — commit 8050bc4

Standing review was COMMENTED; this re-review is REQUEST_CHANGES: 1 blocking finding(s) now stand.

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

No longer blocking:

  • Declare SendSource as Hashable
  • Declare AddressForm Equatable before comparing forms

The domain model is well covered by focused tests, target membership is present, and the CI snapshot is green for this head. One outcome classification is incorrect for definitive shielded broadcast failures and blocks safe retry on direct Shielded/Platform sends; two lower-severity domain consistency issues remain.

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: Non-Core dash: links drop label and message
DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift:72-76

When a dash: link contains a Platform address, Shielded address, or Identity ID, the parser reconstructs Destination with only the type, text, script form, and amount. The same link parser preserves label and message for Core destinations, so non-Core links silently discard merchant-provided metadata even though Destination models both fields. The comment justifies dropping the request URL for non-Core links, not dropping these independent fields.

return .success(Destination(type: destination.type, text: destination.text,
                                    isScriptForm: destination.isScriptForm, amountDuffs: link.amount,
                                    label: link.label, message: link.message))

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

🟡 Suggestion: SendBalances fabricates zero for identity
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendPairPolicy.swift:24-30

SendBalances stores only Core, Shielded, and Platform L1 duffs, while Identity funds are credits represented elsewhere by IdentityCreditBalance. Returning 0 for .identity makes an absent or differently-unitized balance look like a real zero balance. startingSource currently excludes Identity from auto-picking, but the public method still accepts every SendSource, so a future caller could silently treat an Identity source as empty rather than discovering the unit mismatch.

func balance(of source: SendSource) -> UInt64 {
    switch source {
    case .core: return core
    case .shielded: return shielded
    case .platform: return platform
    case .identity: preconditionFailure("identity balance is credits, not duffs in SendBalances")
    }
}

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

Same commit as the standing review; the inline threads above carry the per-finding outcome. This follow-up exists only to correct the verdict.

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 large cross-cutting domain-model change that defines destination parsing, routing, amount validation, and send outcomes, but the diff does not itself perform funds movement, signing, key handling, consensus, or other critical-surface operations.
  • 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
  • Code unchanged since the last final review (8050bc47): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed; 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 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/Domain/SendOutcome.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:117-136: Do not classify definitive shielded broadcast failures as in-flight
  `PlatformWalletError.shieldedBroadcastFailed` is documented by the pinned SwiftDashSDK as a definitive failure: the shielded transition was not executed and spent notes were released, so retry is safe. This mapper leaves the case in the `default` branch and returns `.inFlight`, suppressing Retry for direct Shielded/Platform sends that are known not to have executed. The same error can also arise during a Core asset-lock second leg, where the result must remain in-flight if the asset lock was already recorded, so adding a universal enum case is not sufficient; the route/phase must be supplied to this mapping or the executor must normalize the error before calling it. The current `testPlatformRejectionAfterHandoverIsInFlight` test incorrectly treats this definitive failure as universally in-flight.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: For a direct Shielded-to-* or Platform-to-Shielded send, a `PlatformWalletError.shieldedBroadcastFailed` reaches `SendOutcome(error:)` and falls through to `.inFlight`, so the result suppresses Retry even though the SDK guarantees that the shielded transition was not executed and the spent notes were released. The same mapper also recursively applies this classification to a Core asset-lock second leg, where `.inFlight` is correct, so the error cannot be fixed with a universal enum mapping._

@romchornyi
romchornyi force-pushed the feat/external-send-domain branch from 8050bc4 to d30bf44 Compare November 13, 2026 21:07
@romchornyi

Copy link
Copy Markdown
Contributor Author

Re-review at 8050bc4, addressed in d30bf44:

  • Code 16 shieldedBroadcastFailed → .inFlight (SendOutcome.swift:117-136): deferred to the platform pin bump (feat(wallet): send from every balance to every destination type in the new Send flow #1358). On the platform commit this app is pinned to (.platform-ref dabbec09c9), ErrorShieldedBroadcastFailed also covers a relay/CheckTx refusal or Platform's execution error (error.rs#L137-L144), an unproved node verdict, so offering Retry there could pay twice. Later platform narrows code 16 to a transition that never left the wallet and reports node verdicts as shieldedSpendUnconfirmed; the mapping changes to not sent for the direct routes together with that pin.
  • Non-Core dash: links drop label and message: fixed; Platform, Shielded and Identity links keep them as Core links do.
  • SendBalances fabricates zero for identity: fixed; balance(of:) returns nil for Identity, whose credits SendBalances does not hold.

@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 external-send domain model and input-boundary changes are otherwise consistent with the reviewed architecture, and the completed target-membership, workflow, accessibility, and CodeRabbit checks passed. One blocking outcome-classification defect remains: the pinned SDK explicitly marks shielded broadcast failures and address-nonce mismatches as definitive non-execution cases that safely permit retry, but this head still reports both as in flight; the simulator test check was still running.

🔴 1 blocking

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 domain-model change affecting destination parsing, network validation, send-route policy, amount rules, and outcome mapping, but the diff does not itself implement funds movement, cryptography, key handling, or other critical-surface behavior.
  • 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 `DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:117-136: Do not classify definitive shielded broadcast failures as in-flight
  The pinned Platform revision in `.platform-ref` documents both `ErrorShieldedBroadcastFailed` and `ErrorAddressNonceMismatch` as definitive failures: the transition did not execute, reservations were released, and retry is safe. Because `PlatformWalletError.shieldedBroadcastFailed` and `.addressNonceMismatch` are not handled here, they fall through to `default: .inFlight`, which removes the Retry path and tells the user that a payment may still be processing even though the SDK says no funds left the source. Deferring this to the later pin bump does not resolve the defect for the SDK revision this app currently consumes.

Comment on lines +117 to +136
private static func outcome(for error: PlatformWalletError) -> SendOutcome {
switch error {
case .transactionBroadcastRejected:
return .notSent(.rejected)
case .signingKeyUnavailable:
return .notSent(.signingKeyUnavailable)
case .staleReservationToken, .coreInsufficientFunds, .shieldedNoRecordedAnchor:
return .notSent(.failed)
// Refusals of an asset lock's coin selection: nothing was built or broadcast.
case .assetLockInsufficientFunds, .noSelectableInputs, .assetLockTooManyInputs:
return .notSent(.failed)
// The only producer of this code is the FFI's `identity_manager_remove_identity`, which no send calls.
case .identityNotFound:
return .notSent(.identityNotFound)
// The Platform withdrawal's address network check runs before signing; the Platform-to-shielded capacity
// checks run during input selection and the input fetch, before the proof is built.
case .invalidNetwork, .shieldedInsufficientBalance:
return .notSent(.failed)
default:
return .inFlight

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

⚖️ Disputed (left to the maintainers; not blocking) at f5e8f706; see the replies below.

🔴 Blocking: Do not classify definitive shielded broadcast failures as in-flight

The pinned Platform revision in .platform-ref documents both ErrorShieldedBroadcastFailed and ErrorAddressNonceMismatch as definitive failures: the transition did not execute, reservations were released, and retry is safe. Because PlatformWalletError.shieldedBroadcastFailed and .addressNonceMismatch are not handled here, they fall through to default: .inFlight, which removes the Retry path and tells the user that a payment may still be processing even though the SDK says no funds left the source. Deferring this to the later pin bump does not resolve the defect for the SDK revision this app currently consumes.

Suggested change
private static func outcome(for error: PlatformWalletError) -> SendOutcome {
switch error {
case .transactionBroadcastRejected:
return .notSent(.rejected)
case .signingKeyUnavailable:
return .notSent(.signingKeyUnavailable)
case .staleReservationToken, .coreInsufficientFunds, .shieldedNoRecordedAnchor:
return .notSent(.failed)
// Refusals of an asset lock's coin selection: nothing was built or broadcast.
case .assetLockInsufficientFunds, .noSelectableInputs, .assetLockTooManyInputs:
return .notSent(.failed)
// The only producer of this code is the FFI's `identity_manager_remove_identity`, which no send calls.
case .identityNotFound:
return .notSent(.identityNotFound)
// The Platform withdrawal's address network check runs before signing; the Platform-to-shielded capacity
// checks run during input selection and the input fetch, before the proof is built.
case .invalidNetwork, .shieldedInsufficientBalance:
return .notSent(.failed)
default:
return .inFlight
// Definitive shielded failures at the pinned SDK revision did not execute and released reservations.
case .shieldedBroadcastFailed, .addressNonceMismatch:
return .notSent(.failed)
default:
return .inFlight

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 4322c14 for the shielded case: shieldedBroadcastFailed is now .notSent(.failed) and offers Retry. addressNonceMismatch stays in flight on purpose: the Rust-owned delivery class coming in dashpay/platform#5928 classes it as maybe-sent, so the app keeps the safe side until it reads that class.

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 4322c140): The shielded case is now correctly classified, but the pinned platform source still documents address-nonce mismatch as definitively unexecuted and safe to retry. The future platform delivery class is not part of this app revision, so retaining .inFlight remains unsafe for the dependency actually consumed by this head.

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.

Deferred to #1427: the app will read the outcome from the Rust-owned delivery class (dashpay/platform#5928) when the pin moves, instead of a per-code switch. Until then .inFlight is the funds-safe side: no Retry is offered, so nothing is paid twice. The shielded case was fixed in the previous round.

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.

Disputed (re-reviewed at f5e8f706): We still disagree on this one, and my answer is above, so I'm leaving the call to the maintainers. It no longer blocks this pull request, and I won't raise it again unless a later change brings the problem back.

@romchornyi
romchornyi force-pushed the feat/external-send-domain branch from d30bf44 to 4322c14 Compare November 15, 2026 17:24

@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 fixes the shielded broadcast-failure mapping, but the pinned SDK still defines address-nonce mismatch as a definitive, retry-safe failure while this PR maps it to in-flight. The head also conflicts with the current develop tip in the ADR index, and that conflict must be resolved before merge; the simulator test check was still in progress with no reported code-check failure.

🔴 2 blocking

Still open from earlier rounds (1)

  • 🔴 Blocking: Do not classify definitive shielded broadcast failures as in-flight — DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:138-140 (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 large, cross-cutting domain-model change affecting payment destination parsing, network validation, send routing, amount rules, and outcome mapping, but it does not itself execute funds movement, alter consensus, handle keys, or cross an FFI boundary.
  • 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 (d30bf44f): 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 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/README.md`:
- [BLOCKING] docs/adr/README.md:40-49: Resolve the ADR index conflict with the current develop branch
  The current develop tip `a00541e0db15d9c6571ea3249ed7812ec4f35246` adds ADR-0053 to this same table, while this head adds ADR-0036 through ADR-0045 from the older merge base. The merge-tree reports a content conflict in `docs/adr/README.md`; merging without resolving it can lose either the external-send entries or the newer DashConnect entry. Rebase or otherwise resolve the table so both sets of valid ADR entries remain.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: Merging PR head 4322c1408 with develop a00541e0d produces a content conflict in docs/adr/README.md, so the merge cannot complete without manual resolution; choosing either side wholesale would omit the other branch's valid ADR rows._

In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:138-140: Do not classify definitive shielded broadcast failures as in-flight
  (carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1406#discussion_r4569201588)

Comment thread docs/adr/README.md
Comment on lines +40 to +49
| [0036](0036-ship-the-ios-screens-and-the-sdk-binding-as-two-surfaces.md) | Ship the iOS screens and the SDK binding as two surfaces | platform | Proposed | |
| [0037](0037-build-external-send-as-a-new-module-over-the-existing-spend-seams.md) | Build external send as a new module over the existing spend seams | payments | Proposed | |
| [0038](0038-decide-every-source-and-destination-pair-in-one-policy.md) | Decide every source and destination pair in one policy | payments | Proposed | |
| [0039](0039-estimate-the-fee-on-send-and-recompute-it-on-confirm.md) | Estimate the fee on Send and recompute it on Confirm | payments | Superseded | [0043](0043-bind-the-fee-where-the-sdk-can-and-mark-the-rest-as-an-estimate.md) |
| [0040](0040-report-three-send-outcomes-and-retry-only-when-nothing-left-the-source.md) | Report three send outcomes and retry only when nothing left the source | payments | Proposed | |
| [0041](0041-keep-identity-to-shielded-off-in-this-release.md) | Keep Identity to Shielded off in this release | payments | Proposed | |
| [0042](0042-report-moved-to-platform-when-a-shielded-to-identity-top-up-fails-after-the-unshield.md) | Report movedToPlatform when a Shielded to Identity top-up fails after the unshield | payments | Superseded | [0044](0044-top-up-an-identity-from-shielded-in-one-step.md) |
| [0043](0043-bind-the-fee-where-the-sdk-can-and-mark-the-rest-as-an-estimate.md) | Bind the fee where the SDK can and mark the rest as an estimate | payments | Proposed | |
| [0044](0044-top-up-an-identity-from-shielded-in-one-step.md) | Top up an identity from Shielded in one step | payments | Proposed | |
| [0045](0045-add-an-external-identity-top-up-and-a-non-blocking-identity-read-to-the-sdk.md) | Add an external-identity top-up and a non-blocking identity read to the SDK | platform | Proposed | |

@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 f5e8f706; see the replies below.

🔴 Blocking: Resolve the ADR index conflict with the current develop branch

The current develop tip a00541e0db15d9c6571ea3249ed7812ec4f35246 adds ADR-0053 to this same table, while this head adds ADR-0036 through ADR-0045 from the older merge base. The merge-tree reports a content conflict in docs/adr/README.md; merging without resolving it can lose either the external-send entries or the newer DashConnect entry. Rebase or otherwise resolve the table so both sets of valid ADR entries remain.

Raised on code unchanged since the last review, and confirmed by an independent pass: Merging PR head 4322c14 with develop a00541e produces a content conflict in docs/adr/README.md, so the merge cannot complete without manual resolution; choosing either side wholesale would omit the other branch's valid ADR rows.

source: gpt-6.1-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 f5e8f706): The current ADR index lists rows 0036 through 0045 before the existing 0053 row in numeric order, so the previously reported collision is resolved.

@romchornyi

Copy link
Copy Markdown
Contributor Author

The stack is rebased on develop a00541e0d (f5e8f70). The ADR index keeps both sets of rows, in number order (0036–0045 and 0053).

@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 external-send domain model and the available CI checks are generally coherent, but the head contains two blocking issues. AmountRules.swift is compiled into the non-DashPay app without its unconditional IdentityCreditBalance dependency, and the carried address-nonce outcome mapping remains inconsistent with the pinned Platform contract.

🔴 1 blocking

Disputed — left to maintainers (1)

  • 🔴 Blocking: Do not classify definitive shielded broadcast failures as in-flight — DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:117-136 (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 domain-model and parsing change covering payment destinations, network validation, send routing, amount checks, and outcome mapping, but the diff does not itself perform funds movement, signing, key handling, or other critical-surface operations.
  • 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 (4322c140): 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 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 `DashWallet/Sources/UI/Payments/ExternalSend/Domain/AmountRules.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/AmountRules.swift:40-53: Add IdentityCreditBalance to every target that compiles AmountRules
  AmountRules.swift is included in both app source phases, but IdentityCreditBalance.swift is included only in the dashpay source phase. The unconditional references to IdentityCreditBalance.lowBalance in identityMax and check therefore leave the dashwallet target without the symbol when it compiles AmountRules.swift. The successful dashpay CI build does not cover this target. Add IdentityCreditBalance.swift to the dashwallet target as well, or remove this target-specific dependency from AmountRules.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: Compiling the dashwallet target includes AmountRules.swift, whose unconditional references to IdentityCreditBalance cannot resolve because IdentityCreditBalance.swift is not in that target and its declaration is additionally guarded by #if DASHPAY. The dashwallet build therefore fails with an unresolved IdentityCreditBalance symbol._

Comment on lines +40 to +53
let reserve = IdentityCreditBalance.lowBalance
guard let spendable = spendable(balance: balanceCredits, fee: feeCredits), spendable > reserve else {
return .disabledReserveSpent
}
return .amount(spendable - reserve)
}

/// `balance`, `fee` and `amount` are in the source's own unit: duffs for Core, Shielded and Platform,
/// credits for Identity.
static func check(amount: UInt64, source: SendSource, balance: UInt64, fee: UInt64) -> AmountCheck {
guard let spendable = spendable(balance: balance, fee: fee), amount <= spendable else {
return .notEnough
}
if source == .identity, spendable - amount < IdentityCreditBalance.lowBalance {

@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 3d7d56ac; see the replies below.

🔴 Blocking: Add IdentityCreditBalance to every target that compiles AmountRules

AmountRules.swift is included in both app source phases, but IdentityCreditBalance.swift is included only in the dashpay source phase. The unconditional references to IdentityCreditBalance.lowBalance in identityMax and check therefore leave the dashwallet target without the symbol when it compiles AmountRules.swift. The successful dashpay CI build does not cover this target. Add IdentityCreditBalance.swift to the dashwallet target as well, or remove this target-specific dependency from AmountRules.

Raised on code unchanged since the last review, and confirmed by an independent pass: Compiling the dashwallet target includes AmountRules.swift, whose unconditional references to IdentityCreditBalance cannot resolve because IdentityCreditBalance.swift is not in that target and its declaration is additionally guarded by #if DASHPAY. The dashwallet build therefore fails with an unresolved IdentityCreditBalance symbol.

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 3d7d56a. AmountRules now holds the reserve as identityReserveCredits, so it no longer reads the DashPay-only IdentityCreditBalance; AmountRulesTests checks that the two values agree, and the Send screen preview reads the new constant.

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 3d7d56ac): The current AmountRules implementation owns the reserve as identityReserveCredits and no longer depends on the DashPay-only IdentityCreditBalance symbol, removing the cross-target compilation defect.

The pure core of the new external send, with no screen or service using it
yet: the destination types and a parser for every address form, link and
Identity ID (network-checked), the four send sources and the routes between
them, one policy that decides every source and destination pair, the amount
rules, the Confirm warnings, and the three send outcomes the errors of the
existing spend paths map to (only "not sent" offers Retry).

Supporting changes: ScriptAddressCodec decodes an address's form and hash
whatever its network, DashAddressClassifier decodes bech32m without reading
the global network, PaymentNetworkResolver maps any network kind, and
WalletSendService's error domain and codes become readable so a send outcome
can be told from them. The old Send's Confirm texts move to SendWarningText
so both Sends show the same words.

The feature's decisions are recorded as ADR-0036 to ADR-0045 (docs/adr/).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SDD-Published-From: 306145f65dadd33ec186527e30890c7bb756d635
@romchornyi
romchornyi force-pushed the feat/external-send-domain branch from f5e8f70 to 3d7d56a 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 exact reviewed head adds an isolated external-send domain layer with destination parsing, route policy, amount rules, and outcome mapping, with the completed simulator, membership, workflow-lint, and accessibility checks passing. One non-blocking documentation defect remains: the new ADRs link to a feature-summary file that is absent from this head.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(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: Do not link new ADRs to a missing feature-summary file
docs/adr/0037-build-external-send-as-a-new-module-over-the-existing-spend-seams.md:46

This ADR links to ../features/external-send/README.md, but that path does not exist at the reviewed head. The same missing feature-summary reference appears throughout the new external-send ADRs, so readers opening these records from the current repository encounter dead internal links. Add the feature summary in this PR or replace the links with an artifact that exists at this head; if stacked PR #1409 is intended to provide it, keep that dependency explicitly tracked.

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: 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 large, cross-cutting domain-model and parsing change with substantial send-policy and outcome logic, but the diff does not itself perform funds movement, cryptography, key handling, or consensus-critical operations.
  • 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
  • Code unchanged since the last final review (f5e8f706): 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, 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. Verify the current code and confirm that no unresolved issues remain.

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

Not approved: 1 blocking finding(s) are disputed and left to the maintainers.

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