Repository navigation
feat(wallet): send from every balance to every destination type in the new Send flow - #1358
romchornyi wants to merge 4 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
|
🕓 Review not started yet because this PR is a draft.
Commit e859ec2. Normal review starts when eligible; priority review starts as soon as a slot is available. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified head 0136d8f against the changed source, relevant callers, and the pinned Platform implementation; the simulator and recovery CI logs confirm two compilation regressions. Ten blocking findings remain after consolidating the identity top-up eligibility failures; one lower-priority recovery-marker suggestion concerning the limitation tracked in dashpay/platform#5824 is omitted under the comment budget. This was a static review; no local builds or tests were run.
🔴 10 blocking
10 finding(s) not shown inline (GitHub refused the PR diff as too large)
🔴 Blocking: Qualify the controller presentation call to restore compilation
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:130
The local zero-argument closure named present shadows the inherited presentation method, so this expression calls that closure with arguments and does not compile. The exact-head simulator job's Build for testing log confirms ExternalSendHostController.swift:130:20: error: argument passed to call that takes no arguments in Actions run 42916551889. Explicitly invoke the controller method.
self.present(controller, animated: true)
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)
🔴 Blocking: Keep the recovery harness compatible with the confirmation initializer
DashWallet/Sources/UI/Payments/InternalTransfer/Shielded/CoreShieldedDrainMaxController.swift:226
The new init(context:quote:) is defined in CoreShieldedDrainService.swift, but the recovery harness compiles this controller against the generated CoreShieldedDrainConfirmation in scripts/core_drain_recovery_harness.py. That stub still exposes only the memberwise initializer. The exact-head recovery log in Actions run 42916551972 reports extra argument 'quote' in call and missing memberwise arguments at this line. Update the harness edge to provide the initializer, or retain the constructor supported by both compilation contexts.
self.confirmation = CoreShieldedDrainConfirmation(
context: context, candidateBalanceDuffs: quote.candidateBalanceDuffs,
estimatedRecipientCredits: quote.estimatedRecipientCredits,
estimatedL1FeeDuffs: quote.estimatedL1FeeDuffs, poolFeeCredits: quote.poolFeeCredits)
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, security-auditor); gpt-6-astra (phase2-reviewer: general, security-auditor)
🔴 Blocking: Bind BIP70 confirmation details to the request actually signed
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:504-510
ExternalSendFlow.open fetches the payment request and stores its primary address, merchant name, memo, and verification status in Destination. This preparation fetches it again but compares only the total amount before building the new outputs. PreparedPaymentRequestSend returns no replacement recipient or verification information, while ConfirmViewModel continues rendering the original Destination. Equal-total responses with different outputs can therefore produce a transaction whose recipient differs from Confirm; a changed verification status also leaves the original verified-merchant label displayed. Preserve and build the original verified Confirmation, or bind the refreshed outputs and verification context to the confirmation UI and require review of any changes. Add regression coverage for equal totals with different recipients and verification states.
source: gpt-6.1-sol (phase2-reviewer: general, security-auditor); gpt-6-astra (phase2-reviewer: general, security-auditor)
🔴 Blocking: Prepare an executable fee-bound plan for routed sends
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:374-376
prepareRouted reruns the Send estimator and stores only the destination; it does not prepare a transaction or constrain the eventual debit. Most live adapters ignore bindingFeeDuffs or bindingFeeCredits when building and submitting. For example, ExternalSendFeeEstimator always prices Shielded spends at two actions, whereas the pinned SDK's select_notes_with_fee computes the fee from the selected note count. A payment requiring more notes can therefore debit more than Confirm's displayed fee and total. Platform transfer reserves and Identity minimum fees likewise are not prepared transaction fees. Obtain and retain an executable plan or enforceable fee bound from the owning spend/SDK layer, then execute that plan. Missing SDK preparation capabilities require an upstream change; another estimate must not be presented as the binding preparation promised by this PR and proposed ADR-0039.
source: gpt-6.1-sol (phase2-reviewer: general, security-auditor); gpt-6-astra (phase2-reviewer: general, security-auditor)
🔴 Blocking: Enforce the SDK's identity top-up prerequisites before confirmation
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:824-829
The new identity top-up routes bypass prerequisites enforced by their execution seams:
• Foreign recipients: both calls reach ManagedPlatformWallet.topUpFromAddresses. At pin 1721ca7a8b, IdentityWallet.top_up_from_addresses requires the recipient in the wallet's identity manager and otherwise returns IdentityNotFound before submission. The destination lookup only queries sdk.identityGet and does not populate that manager. A normal foreign identity therefore cannot be paid; Platform reports the local refusal as in progress, while Shielded first unshields funds and then fails.
• Platform Max: LiveSendMaxPlanner subtracts the observed 41,500,000-credit fee from the aggregate balance, but IdentityCreditsTopUp.fromPlatform uses makeInputs, which requires 200,000,000 credits of retained headroom and can exclude addresses that cannot serve as the fee source. Even a single funded address produces an unexecutable Max. Reuse currentCandidates, maxFundableDuffs, and the corresponding typed-amount eligibility check.
• Core minimum: the sibling toIdentity path accepts amounts below 50,500 duffs. The pinned FFI rejects them before building any lock, but lockMayExist classifies that refusal as possibly recorded, producing an in-progress result with nothing to recover.
Use route-aware top-up preflight before enabling Confirm. Add an external-recipient-capable SDK operation or disable foreign-recipient pairs until supported; do not register foreign identities as owned. Reject sub-minimum Core amounts as unsent rather than progress.
source: gpt-6.1-sol (phase2-reviewer: general, security-auditor); gpt-6-astra (phase2-reviewer: general, security-auditor)
🔴 Blocking: Preserve the native-credit amount of a Shielded Max plan
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:142-146
Dividing plan.amountCredits by 1000 discards its fractional-duff remainder, and SendAmountRequest carries only the resulting duff amount. LiveShieldedPlatformSend reconstructs credits by multiplying that amount by 1000 and passes sweepAll: true. All three Shielded coordinator methods require exact equality with the freshly read sweep plan, so a plan not divisible by 1000 fails as shieldedSweepChanged even when the wallet has not changed; retry repeats the same rounding. The existing SendViewModel preserves shieldedSweepAmountCredits separately for this reason. Carry the exact native-credit amount or sweep plan through preparation and execution, converting only for display, and cover the live coordinator equality check rather than stopping at fake preparation.
source: gpt-6.1-sol (phase2-reviewer: general, security-auditor); gpt-6-astra (phase2-reviewer: general, security-auditor)
🔴 Blocking: Recheck payment-request expiry at the actual send boundary
DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:315-317
The split API checks expiry in buildForSend, which ExternalSend now invokes before the user reviews Confirm. postAndBroadcast performs no further expiry check. Leaving Confirm open or backgrounding the app until the request expires therefore still permits the signed payment to be POSTed and broadcast. An unsigned request without a payment URL has no merchant round-trip that could refuse it. Keep the early check, but also validate expiry immediately before releasing signed bytes or broadcasting, and classify a refusal at that point as unsent. Add coverage for expiry between buildForSend and postAndBroadcast.
source: gpt-6-astra (phase2-reviewer: general)
🔴 Blocking: Preserve sender callbacks for ordinary dash links
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:282-284
DestinationParser retains a validated callbackScheme for an ordinary dash link opened by another app, but the standard-send plan discards it. The standard execution branch only broadcasts; prepared.opens is called exclusively for BIP70 sends. Since performPayToURL now routes links into ExternalSend, a successful plain-address payment no longer sends the acknowledgement previously produced by DWPaymentProcessor.sendCompletedToAddress. Preserve the callback context for standard sends and construct the URL with CallbackScheme.payAckURL only after successful broadcast, retaining the existing suppression for scanned and pasted links.
source: gpt-6-astra (phase2-reviewer: general)
🔴 Blocking: Move the blocking identity query off the main actor in SwiftDashSDK
DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift:73-80
Awaiting identityGet does not make this network operation nonblocking. At pin 1721ca7a8b, SDK.identityGet is explicitly @mainactor and directly invokes dash_sdk_identity_fetch; that Rust entry point executes runtime.block_on around the network fetch. Resolving an Identity ID therefore blocks the UI thread for the DAPI request, including slow-network timeout periods, instead of keeping Address responsive in its checking state. Correct the query wrapper in the owning SwiftDashSDK repository and consume the corrected pin. A detached task around this caller alone is insufficient because the SDK method still hops to the main actor.
source: gpt-6.1-sol (phase2-reviewer: general, security-auditor); gpt-6-astra (phase2-reviewer: general, security-auditor)
🔴 Blocking: Bound encoded address lengths before Base58 decoding
DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift:86-88
Every bare candidate reaches decodeAddress without an encoded-length bound, and the Identity ID fallback calls base58Decode without one as well. That decoder allocates a buffer proportional to input length and traverses the entire buffer for each input character, giving quadratic work before checksum or payload-length rejection. These new parsing paths run synchronously on the main actor, including showClipboard and scannedDestination, so oversized external text can make the wallet unresponsive. Apply format-specific encoded-length limits before both Base58 decoding calls, including candidates extracted from clipboard text, while allowing the legitimate Bech32m formats through their own bounded validation. Moving unbounded decoding off-main would not resolve the resource-consumption problem.
source: gpt-6.1-sol (phase2-reviewer: general, security-auditor); gpt-6-astra (phase2-reviewer: general, security-auditor)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate change directly modifies funds movement in ExternalSendExecutor.swift and CoreFundingResumer.swift, including multi-stage transfers, broadcast outcomes, and retry decisions that must prevent duplicate spending. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— general (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort xhigh); agentphase2-reviewer - Model comparison: every Phase-2 reviewer also ran on
gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendHostController.swift:130: Qualify the controller presentation call to restore compilation
The local zero-argument closure named `present` shadows the inherited presentation method, so this expression calls that closure with arguments and does not compile. The exact-head simulator job's Build for testing log confirms `ExternalSendHostController.swift:130:20: error: argument passed to call that takes no arguments` in Actions run 42916551889. Explicitly invoke the controller method.
In `DashWallet/Sources/UI/Payments/InternalTransfer/Shielded/CoreShieldedDrainMaxController.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/InternalTransfer/Shielded/CoreShieldedDrainMaxController.swift:226: Keep the recovery harness compatible with the confirmation initializer
The new `init(context:quote:)` is defined in CoreShieldedDrainService.swift, but the recovery harness compiles this controller against the generated CoreShieldedDrainConfirmation in scripts/core_drain_recovery_harness.py. That stub still exposes only the memberwise initializer. The exact-head recovery log in Actions run 42916551972 reports `extra argument 'quote' in call` and missing memberwise arguments at this line. Update the harness edge to provide the initializer, or retain the constructor supported by both compilation contexts.
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:504-510: Bind BIP70 confirmation details to the request actually signed
ExternalSendFlow.open fetches the payment request and stores its primary address, merchant name, memo, and verification status in Destination. This preparation fetches it again but compares only the total amount before building the new outputs. PreparedPaymentRequestSend returns no replacement recipient or verification information, while ConfirmViewModel continues rendering the original Destination. Equal-total responses with different outputs can therefore produce a transaction whose recipient differs from Confirm; a changed verification status also leaves the original verified-merchant label displayed. Preserve and build the original verified Confirmation, or bind the refreshed outputs and verification context to the confirmation UI and require review of any changes. Add regression coverage for equal totals with different recipients and verification states.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:374-376: Prepare an executable fee-bound plan for routed sends
prepareRouted reruns the Send estimator and stores only the destination; it does not prepare a transaction or constrain the eventual debit. Most live adapters ignore bindingFeeDuffs or bindingFeeCredits when building and submitting. For example, ExternalSendFeeEstimator always prices Shielded spends at two actions, whereas the pinned SDK's select_notes_with_fee computes the fee from the selected note count. A payment requiring more notes can therefore debit more than Confirm's displayed fee and total. Platform transfer reserves and Identity minimum fees likewise are not prepared transaction fees. Obtain and retain an executable plan or enforceable fee bound from the owning spend/SDK layer, then execute that plan. Missing SDK preparation capabilities require an upstream change; another estimate must not be presented as the binding preparation promised by this PR and proposed ADR-0039.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:824-829: Enforce the SDK's identity top-up prerequisites before confirmation
The new identity top-up routes bypass prerequisites enforced by their execution seams:
• Foreign recipients: both calls reach ManagedPlatformWallet.topUpFromAddresses. At pin 1721ca7a8b, IdentityWallet.top_up_from_addresses requires the recipient in the wallet's identity manager and otherwise returns IdentityNotFound before submission. The destination lookup only queries sdk.identityGet and does not populate that manager. A normal foreign identity therefore cannot be paid; Platform reports the local refusal as in progress, while Shielded first unshields funds and then fails.
• Platform Max: LiveSendMaxPlanner subtracts the observed 41,500,000-credit fee from the aggregate balance, but IdentityCreditsTopUp.fromPlatform uses makeInputs, which requires 200,000,000 credits of retained headroom and can exclude addresses that cannot serve as the fee source. Even a single funded address produces an unexecutable Max. Reuse currentCandidates, maxFundableDuffs, and the corresponding typed-amount eligibility check.
• Core minimum: the sibling toIdentity path accepts amounts below 50,500 duffs. The pinned FFI rejects them before building any lock, but lockMayExist classifies that refusal as possibly recorded, producing an in-progress result with nothing to recover.
Use route-aware top-up preflight before enabling Confirm. Add an external-recipient-capable SDK operation or disable foreign-recipient pairs until supported; do not register foreign identities as owned. Reject sub-minimum Core amounts as unsent rather than progress.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:282-284: Preserve sender callbacks for ordinary dash links
DestinationParser retains a validated callbackScheme for an ordinary dash link opened by another app, but the standard-send plan discards it. The standard execution branch only broadcasts; prepared.opens is called exclusively for BIP70 sends. Since performPayToURL now routes links into ExternalSend, a successful plain-address payment no longer sends the acknowledgement previously produced by DWPaymentProcessor.sendCompletedToAddress. Preserve the callback context for standard sends and construct the URL with CallbackScheme.payAckURL only after successful broadcast, retaining the existing suppression for scanned and pasted links.
In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:142-146: Preserve the native-credit amount of a Shielded Max plan
Dividing plan.amountCredits by 1000 discards its fractional-duff remainder, and SendAmountRequest carries only the resulting duff amount. LiveShieldedPlatformSend reconstructs credits by multiplying that amount by 1000 and passes sweepAll: true. All three Shielded coordinator methods require exact equality with the freshly read sweep plan, so a plan not divisible by 1000 fails as shieldedSweepChanged even when the wallet has not changed; retry repeats the same rounding. The existing SendViewModel preserves shieldedSweepAmountCredits separately for this reason. Carry the exact native-credit amount or sweep plan through preparation and execution, converting only for display, and cover the live coordinator equality check rather than stopping at fake preparation.
In `DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift`:
- [BLOCKING] DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:315-317: Recheck payment-request expiry at the actual send boundary
The split API checks expiry in buildForSend, which ExternalSend now invokes before the user reviews Confirm. postAndBroadcast performs no further expiry check. Leaving Confirm open or backgrounding the app until the request expires therefore still permits the signed payment to be POSTed and broadcast. An unsigned request without a payment URL has no merchant round-trip that could refuse it. Keep the early check, but also validate expiry immediately before releasing signed bytes or broadcasting, and classify a refusal at that point as unsent. Add coverage for expiry between buildForSend and postAndBroadcast.
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift:73-80: Move the blocking identity query off the main actor in SwiftDashSDK
Awaiting identityGet does not make this network operation nonblocking. At pin 1721ca7a8b, SDK.identityGet is explicitly @MainActor and directly invokes dash_sdk_identity_fetch; that Rust entry point executes runtime.block_on around the network fetch. Resolving an Identity ID therefore blocks the UI thread for the DAPI request, including slow-network timeout periods, instead of keeping Address responsive in its checking state. Correct the query wrapper in the owning SwiftDashSDK repository and consume the corrected pin. A detached task around this caller alone is insufficient because the SDK method still hops to the main actor.
In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift:86-88: Bound encoded address lengths before Base58 decoding
Every bare candidate reaches decodeAddress without an encoded-length bound, and the Identity ID fallback calls base58Decode without one as well. That decoder allocates a buffer proportional to input length and traverses the entire buffer for each input character, giving quadratic work before checksum or payload-length rejection. These new parsing paths run synchronously on the main actor, including showClipboard and scannedDestination, so oversized external text can make the wallet unresponsive. Apply format-specific encoded-length limits before both Base58 decoding calls, including candidates extracted from clipboard text, while allowing the legitimate Bech32m formats through their own bounded validation. Moving unbounded decoding off-main would not resolve the resource-consumption problem.
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (queue backlog)
At head 54dd5dd, seven prior findings are fixed; this verification also confirms missing recipient-safe Core-to-Shielded recovery and full-recipient inspection. The current simulator CI run fails before the app build because the extracted top-up helper breaks the compatibility harness added on develop; accessibility, workflow lint, target membership, and recovery checks pass. Verification was static only, and funded end-to-end validation remains outstanding.
🔴 5 blocking | 🟡 1 suggestion(s)
6 finding(s) not shown inline (GitHub refused the PR diff as too large)
🔴 Blocking: Move the blocking identity query off the main actor in SwiftDashSDK
DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift:73-80
At the pinned platform commit 1721ca7a8b, both identityGet and dpnsGetUsername are explicitly @mainactor and directly invoke synchronous FFI. Their Rust implementations wait for network responses with runtime.block_on. These awaits therefore block the UI during both queries, including retries and timeouts; the non-main-actor app adapter does not change the SDK methods' isolation. Identity-ID scans automatically enter this path, so navigation and cancellation can freeze before authentication. Move both reads onto SwiftDashSDK's lifecycle-safe performBlockingQuery mechanism and consume the updated SDK revision. ADR-0045 describes that work but does not implement it, and wrapping the existing methods in an app-side detached task would still hop back to the main actor.
source: gpt-6.1-sol (phase2-reviewer: general)
🔴 Blocking: Enforce the SDK's identity top-up prerequisites before confirmation
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:859-867
The policy offers Platform-to-foreign-Identity payments, but this adapter calls IdentityCreditsTopUp.fromPlatform, which delegates to wallet.topUpFromAddresses. At the pinned SDK revision, IdentityWallet::top_up_from_addresses first resolves the recipient through this wallet's identity manager and returns IdentityNotFound when it is not managed locally, before submitting anything. A valid external recipient therefore passes lookup and confirmation but cannot receive the payment. The returned error also falls through SendOutcome's default mapping to inFlight, incorrectly telling the user it will finish automatically. Integrate an external-identity top-up operation in rs-platform-wallet and consume it through the bindings, or make this source/destination pair unavailable before confirmation. Do not register the recipient as an owned identity.
source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer)
🔴 Blocking: Prepare an executable fee-bound plan for routed sends
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:395-400
For Shielded-source sends, preparation still retains only the destination, amount, and estimate—not selected inputs or an executable fee-bound plan. ExternalSendFeeEstimator always requests two Shielded actions, while the pinned Rust select_notes_with_fee computes the authoritative fee from the actual selected-note count during execution. A multi-note payment can pass requireFits here but later debit a larger fee or fail because amount plus the real fee exceeds the balance, even without an intervening wallet change. The new '~' labels correctly disclose estimates, but the executable Shielded preparation chosen in ADR-0043 remains absent. Add preparation in the owning Rust wallet layer, expose the resulting plan and authoritative fee through SwiftDashSDK, and execute that plan or refuse it when stale; update the SDK pin before enabling that contract.
source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer)
🔴 Blocking: Keep an unfinished Core-to-Shielded send resumable to its recipient
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:613-618
After a non-Max Core-to-Shielded send records an asset lock but fails or becomes unconfirmed before completion, this adapter returns only an outcome and discards the coordinator's outpoint/recipient continuation. The executor converts that outcome to inFlight, and the flow closes with 'It will finish on its own.' Shared recovery is user-initiated, however, and calls resumeAssetLock without the external recipient. For a non-drain lock, that method falls back to env.shieldedRecipient; the pinned SDK accepts that supplied recipient, so recovery can return the funds to the sender instead of paying the payee. Develop's f69f35c adds same-recipient Resume only to the old Send sheet, not this executor. Preserve a same-outpoint continuation here and integrate the SDK-persisted recipient support from dashpay/platform#5762 into shared recovery. Updating the SDK alone does not make this flow finish automatically or supply the correct resume recipient.
source: gpt-6.1-sol (phase2-reviewer: general)
🔴 Blocking: Update the top-up compatibility harness for the extracted helper
DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift:703-710
This extraction removes IdentityTopUpViewModel.topUpFromShielded and replaces it with IdentityCreditsTopUp.fromShielded, but the compatibility harness added by develop's f69f35c still extracts 'private func topUpFromShielded(' from this file and assembles only the previous ViewModel-based implementation. The head-triggered simulator CI run 43007501297 fails on its PR merge checkout in 'Test recovery bookkeeping and uncertain top-up outcomes': scripts/test_identity_top_up_compatibility.py reaches production.index(marker) and raises 'ValueError: substring not found'. Consequently, the app build and DashWalletTests are skipped. Update the harness and fixtures to exercise the extracted shared helper while preserving the current base's uncertain-outcome coverage. This is a semantic integration failure despite the reported conflict-free merge.
source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)
🟡 Suggestion: Provide a full-recipient inspection control before confirming
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:550-554
Send displays this shortened address, and ConfirmViewModel.toText uses the same helper; neither screen offers a full-address disclosure. For Platform and Shielded addresses, much or all of the displayed prefix identifies the network/type rather than the recipient, leaving very little recipient-specific text to verify. Scanned and externally opened destinations can also enter Send without populating the Address field, so navigating back does not reliably expose the full destination. Keep the compact summary, but add an accessible control on Send or Confirm that reveals the complete recipient before authorization to send.
source: gpt-6.1-sol (phase2-reviewer: security-auditor)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate change directly implements funds-movement orchestration in ExternalSendExecutor.swift and adds external funding and identity top-up paths in PlatformAddressSyncCoordinator.swift and ShieldedTransferCoordinator.swift, including fee binding, partial completion, and retry safety. - Phase 1 reviewers: not run (skipped for throughput: 18 PRs queued, above the 10 limit)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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/IdentityLookupService.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift:73-80: Move the blocking identity query off the main actor in SwiftDashSDK
At the pinned platform commit 1721ca7a8b, both identityGet and dpnsGetUsername are explicitly @MainActor and directly invoke synchronous FFI. Their Rust implementations wait for network responses with runtime.block_on. These awaits therefore block the UI during both queries, including retries and timeouts; the non-main-actor app adapter does not change the SDK methods' isolation. Identity-ID scans automatically enter this path, so navigation and cancellation can freeze before authentication. Move both reads onto SwiftDashSDK's lifecycle-safe performBlockingQuery mechanism and consume the updated SDK revision. ADR-0045 describes that work but does not implement it, and wrapping the existing methods in an app-side detached task would still hop back to the main actor.
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:859-867: Enforce the SDK's identity top-up prerequisites before confirmation
The policy offers Platform-to-foreign-Identity payments, but this adapter calls IdentityCreditsTopUp.fromPlatform, which delegates to wallet.topUpFromAddresses. At the pinned SDK revision, IdentityWallet::top_up_from_addresses first resolves the recipient through this wallet's identity manager and returns IdentityNotFound when it is not managed locally, before submitting anything. A valid external recipient therefore passes lookup and confirmation but cannot receive the payment. The returned error also falls through SendOutcome's default mapping to inFlight, incorrectly telling the user it will finish automatically. Integrate an external-identity top-up operation in rs-platform-wallet and consume it through the bindings, or make this source/destination pair unavailable before confirmation. Do not register the recipient as an owned identity.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:395-400: Prepare an executable fee-bound plan for routed sends
For Shielded-source sends, preparation still retains only the destination, amount, and estimate—not selected inputs or an executable fee-bound plan. ExternalSendFeeEstimator always requests two Shielded actions, while the pinned Rust select_notes_with_fee computes the authoritative fee from the actual selected-note count during execution. A multi-note payment can pass requireFits here but later debit a larger fee or fail because amount plus the real fee exceeds the balance, even without an intervening wallet change. The new '~' labels correctly disclose estimates, but the executable Shielded preparation chosen in ADR-0043 remains absent. Add preparation in the owning Rust wallet layer, expose the resulting plan and authoritative fee through SwiftDashSDK, and execute that plan or refuse it when stale; update the SDK pin before enabling that contract.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:613-618: Keep an unfinished Core-to-Shielded send resumable to its recipient
After a non-Max Core-to-Shielded send records an asset lock but fails or becomes unconfirmed before completion, this adapter returns only an outcome and discards the coordinator's outpoint/recipient continuation. The executor converts that outcome to inFlight, and the flow closes with 'It will finish on its own.' Shared recovery is user-initiated, however, and calls resumeAssetLock without the external recipient. For a non-drain lock, that method falls back to env.shieldedRecipient; the pinned SDK accepts that supplied recipient, so recovery can return the funds to the sender instead of paying the payee. Develop's f69f35c5a adds same-recipient Resume only to the old Send sheet, not this executor. Preserve a same-outpoint continuation here and integrate the SDK-persisted recipient support from dashpay/platform#5762 into shared recovery. Updating the SDK alone does not make this flow finish automatically or supply the correct resume recipient.
In `DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift:703-710: Update the top-up compatibility harness for the extracted helper
This extraction removes IdentityTopUpViewModel.topUpFromShielded and replaces it with IdentityCreditsTopUp.fromShielded, but the compatibility harness added by develop's f69f35c5a still extracts 'private func topUpFromShielded(' from this file and assembles only the previous ViewModel-based implementation. The head-triggered simulator CI run 43007501297 fails on its PR merge checkout in 'Test recovery bookkeeping and uncertain top-up outcomes': scripts/test_identity_top_up_compatibility.py reaches production.index(marker) and raises 'ValueError: substring not found'. Consequently, the app build and DashWalletTests are skipped. Update the harness and fixtures to exercise the extracted shared helper while preserving the current base's uncertain-outcome coverage. This is a semantic integration failure despite the reported conflict-free merge.
In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:550-554: Provide a full-recipient inspection control before confirming
Send displays this shortened address, and ConfirmViewModel.toText uses the same helper; neither screen offers a full-address disclosure. For Platform and Shielded addresses, much or all of the displayed prefix identifies the network/type rather than the recipient, leaving very little recipient-specific text to verify. Scanned and externally opened destinations can also enter Send without populating the Address field, so navigating back does not reliably expose the full destination. Keep the compact summary, but add an accessible control on Send or Confirm that reveals the complete recipient before authorization to send.
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.
- Reject overflowing BIP70 output totals — BIP70PaymentService.prepareForConfirmation sums merchant-controlled output amounts with unchecked UInt64 addition, so an overflowing total can terminate request preparation. The same aggregation and reachable payment-request path exist at the merge base; this PR does not introduce the defect.
- Follow-up: Address this in a separate PR using checked aggregation and valid amount bounds, with regression coverage for malformed merchant output totals.
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
This exact head still has a pre-Confirm preparation leak and leaves new Core-routed sends outside the existing restore-sync and in-flight lifecycle guards; external asset-lock recovery can also lose the confirmed recipient. Exact-head CI has no build or test result (only PR-title and CodeRabbit checks succeeded), and the branch is seven commits behind develop with localization conflicts. One additional valid suggestion about the Identity-to-Core withdrawal warning is omitted under the ten-finding cap.
🔴 9 blocking | 🟡 1 suggestion(s)
10 finding(s) not shown inline (GitHub refused the PR diff as too large)
🟡 Suggestion: Provide a full-recipient inspection control before confirming
DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:546-551
Confirm still derives toText from shortAddress, which exposes only the first six and last five characters or a payment-request host. Neither Send nor Confirm provides an accessible expansion, copy action, or full-recipient details view, so the holder cannot verify the complete destination at the final decision point.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, security-auditor)
🔴 Blocking: Keep an unfinished Core-to-Shielded send resumable to its recipient
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:613-618
The non-Max Core-to-Shielded path passes the external Orchard recipient only to a temporary coordinator. If the asset lock is recorded but the second leg is not confirmed, the executor returns an in-flight outcome and generic recovery later calls resumeAssetLock without recipientOverride; the current non-drain row resolves to the wallet's own Shielded recipient. The related Core-to-Platform external route has the same recovery hazard in CoreFundingResumer: when its UserDefaults recipient record is missing or undecodable and the row is not marked external, recovery falls through to resumeOwn. Preserve the external recipient in the owning recovery/SDK layer and refuse recovery when intent is unknown rather than paying the sender's address.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)
🔴 Blocking: Prepare an executable fee-bound plan for routed sends
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:380-400
Routed preparation stores only destination, amount, the estimated fee, and optional sweep credits in PreparedExternalSend.Plan.routed. Confirm therefore does not retain the selected Shielded notes or an executable fee-bound plan, and the live adapters select inputs and recompute capacity at the Confirm tap. The displayed estimate is marked with ~, but that does not prevent a typed Platform withdrawal or Shielded spend from being accepted through aggregate-balance checks and then rejected after confirmation, nor does it constrain a later fee change. Use the SDK-owned route-specific quote/plan through preparation and execution, or reject/reconfirm whenever the executable capacity or fee plan differs.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)
🔴 Blocking: Enforce the SDK's identity top-up prerequisites before confirmation
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:470-480
The known Core-to-Identity minimum is checked only in runRouted, after Confirm has already been prepared and shown. A positive amount below DWIdentityRegistrationCoordinator.minimumCoreTopUpDuffs can pass Send's aggregate balance and fee checks, authenticate, and open a ready Confirm model before the executor refuses it. Apply this prerequisite during amount validation or preparation, while keeping the execution-time check as a backstop.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)
🔴 Blocking: Move the blocking identity query off the main actor in SwiftDashSDK
DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift:73-80
IdentityLookupService awaits SwiftDashSDKIdentityPlatformReader, but the pinned SDK's identityGet and dpnsGetUsername methods remain main-actor-isolated and synchronously wait for their network-backed FFI calls. A syntactically valid Identity ID from a scan or link can therefore freeze the Address UI, including cancellation and navigation, for the DAPI request duration. Fix the actor isolation in the SDK and consume that pin; moving only the app-side wrapper to an async service does not remove the main-thread block.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)
🔴 Blocking: Bound encoded address lengths before Base58 decoding
DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift:102-103
The 44-character bound applies only to the Base58 paths. An arbitrarily long candidate still reaches DashAddressClassifier.decodeBech32m(text), and find(in:) first tries the complete clipboard string before splitting it into words. Bound the UTF-8 length of Bech32m candidates before calling the decoder so hostile pasted or linked input cannot force an unbounded decode on the UI path.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, security-auditor)
🔴 Blocking: Preserve sender callbacks for ordinary dash links
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:270-285
Although the parser reads an app-opened link's sender scheme, it retains callbackScheme only for Core destinations. Platform, Shielded, and Identity destinations are reconstructed without that provenance, and the routed branch of send never opens a callback URL. An ordinary dash: link opened by another app and paid to a non-Core destination therefore leaves the sender without the callback required by the payment-link contract.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, security-auditor)
🔴 Blocking: Recheck payment-request expiry at the actual send boundary
DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:329-367
postAndBroadcast checks expiry before starting postPayment, but it does not check again after the merchant round-trip completes. If the request expires while the POST is in flight, the code proceeds directly to wallet.broadcast(prepared), so an expired payment request can still be broadcast.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, security-auditor)
🔴 Blocking: Route Core asset-lock sends through the existing restore and in-flight guards
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:367-400
The new routed preparation has no equivalent of WalletSendService.isBlockedByInitialRestoreSync, so Core-to-Shielded, Core-to-Platform, and Core-to-Identity sends can proceed during a restored wallet's initial historical sync once some coins are visible. The external Core-to-Platform execution also calls fundExternalFromCore directly and only records a local Boolean; unlike the sibling coordinator path, it does not call ShieldedAssetLocksInFlight.beginFundingCall/endFundingCall or claim the built outpoint. Wallet removal/reload or a concurrent recovery can therefore race an active external asset-lock operation. Apply the shared restore gate at the Core-funded boundary and use the owning coordinator's funding lifecycle and built-lock claim for the external-recipient variant.
Raised on code unchanged since the last review, and confirmed by an independent pass: During an initial restored-wallet sync, ExternalSend's SendAmountViewModel still enables Continue and prepareRouted proceeds; Core→Shielded's BIP44 path and the direct Core→Platform/Core→Identity calls can therefore build or broadcast from a partial UTXO view instead of refusing the spend. For Core→Platform, fundExternalFromCore only updates the local AssetLockRecord, so wallet removal or recovery can be admitted while the asset-lock call is active and can reload the wallet or concurrently resume the same lock.
source: gpt-6.1-sol (phase2-reviewer: general, security-auditor)
🔴 Blocking: Discard preparations abandoned by navigation
DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:302-320
openConfirm now builds and signs while Send remains interactive. If the user opens Select source, presses Back, or otherwise changes the flow while confirm.start() is suspended, the post-await guard returns without calling confirm.cancel() or recorder.discard on a successful preparation. For BIP70 this leaves the confirmation's single-use claim held even though no POST or broadcast occurred; the next attempt with the same request can fail as already sent. Give preparation explicit cancellation/generation ownership and discard any result that no longer belongs to the active Send state.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The large, intricate change directly alters funds movement in ExternalSendExecutor.swift through preparation, broadcasting, multi-step transfers, Identity credit spending, and failure/retry classification across multiple payment routes. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Code unchanged since the last final review (
54dd5ddf): 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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Send/SendAmountViewModel.swift:546-551: Provide a full-recipient inspection control before confirming
Confirm still derives `toText` from `shortAddress`, which exposes only the first six and last five characters or a payment-request host. Neither Send nor Confirm provides an accessible expansion, copy action, or full-recipient details view, so the holder cannot verify the complete destination at the final decision point.
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:613-618: Keep an unfinished Core-to-Shielded send resumable to its recipient
The non-Max Core-to-Shielded path passes the external Orchard recipient only to a temporary coordinator. If the asset lock is recorded but the second leg is not confirmed, the executor returns an in-flight outcome and generic recovery later calls `resumeAssetLock` without `recipientOverride`; the current non-drain row resolves to the wallet's own Shielded recipient. The related Core-to-Platform external route has the same recovery hazard in `CoreFundingResumer`: when its UserDefaults recipient record is missing or undecodable and the row is not marked external, recovery falls through to `resumeOwn`. Preserve the external recipient in the owning recovery/SDK layer and refuse recovery when intent is unknown rather than paying the sender's address.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:380-400: Prepare an executable fee-bound plan for routed sends
Routed preparation stores only `destination`, `amount`, the estimated fee, and optional sweep credits in `PreparedExternalSend.Plan.routed`. Confirm therefore does not retain the selected Shielded notes or an executable fee-bound plan, and the live adapters select inputs and recompute capacity at the Confirm tap. The displayed estimate is marked with `~`, but that does not prevent a typed Platform withdrawal or Shielded spend from being accepted through aggregate-balance checks and then rejected after confirmation, nor does it constrain a later fee change. Use the SDK-owned route-specific quote/plan through preparation and execution, or reject/reconfirm whenever the executable capacity or fee plan differs.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:470-480: Enforce the SDK's identity top-up prerequisites before confirmation
The known Core-to-Identity minimum is checked only in `runRouted`, after Confirm has already been prepared and shown. A positive amount below `DWIdentityRegistrationCoordinator.minimumCoreTopUpDuffs` can pass Send's aggregate balance and fee checks, authenticate, and open a ready Confirm model before the executor refuses it. Apply this prerequisite during amount validation or preparation, while keeping the execution-time check as a backstop.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:270-285: Preserve sender callbacks for ordinary dash links
Although the parser reads an app-opened link's `sender` scheme, it retains `callbackScheme` only for Core destinations. Platform, Shielded, and Identity destinations are reconstructed without that provenance, and the routed branch of `send` never opens a callback URL. An ordinary `dash:` link opened by another app and paid to a non-Core destination therefore leaves the sender without the callback required by the payment-link contract.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:367-400: Route Core asset-lock sends through the existing restore and in-flight guards
The new routed preparation has no equivalent of `WalletSendService.isBlockedByInitialRestoreSync`, so Core-to-Shielded, Core-to-Platform, and Core-to-Identity sends can proceed during a restored wallet's initial historical sync once some coins are visible. The external Core-to-Platform execution also calls `fundExternalFromCore` directly and only records a local Boolean; unlike the sibling coordinator path, it does not call `ShieldedAssetLocksInFlight.beginFundingCall/endFundingCall` or claim the built outpoint. Wallet removal/reload or a concurrent recovery can therefore race an active external asset-lock operation. Apply the shared restore gate at the Core-funded boundary and use the owning coordinator's funding lifecycle and built-lock claim for the external-recipient variant.
_Raised on code unchanged since the last review, and confirmed by an independent pass: During an initial restored-wallet sync, ExternalSend's SendAmountViewModel still enables Continue and prepareRouted proceeds; Core→Shielded's BIP44 path and the direct Core→Platform/Core→Identity calls can therefore build or broadcast from a partial UTXO view instead of refusing the spend. For Core→Platform, fundExternalFromCore only updates the local AssetLockRecord, so wallet removal or recovery can be admitted while the asset-lock call is active and can reload the wallet or concurrently resume the same lock._
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift:73-80: Move the blocking identity query off the main actor in SwiftDashSDK
`IdentityLookupService` awaits `SwiftDashSDKIdentityPlatformReader`, but the pinned SDK's `identityGet` and `dpnsGetUsername` methods remain main-actor-isolated and synchronously wait for their network-backed FFI calls. A syntactically valid Identity ID from a scan or link can therefore freeze the Address UI, including cancellation and navigation, for the DAPI request duration. Fix the actor isolation in the SDK and consume that pin; moving only the app-side wrapper to an async service does not remove the main-thread block.
In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/DestinationParser.swift:102-103: Bound encoded address lengths before Base58 decoding
The 44-character bound applies only to the Base58 paths. An arbitrarily long candidate still reaches `DashAddressClassifier.decodeBech32m(text)`, and `find(in:)` first tries the complete clipboard string before splitting it into words. Bound the UTF-8 length of Bech32m candidates before calling the decoder so hostile pasted or linked input cannot force an unbounded decode on the UI path.
In `DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift`:
- [BLOCKING] DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:329-367: Recheck payment-request expiry at the actual send boundary
`postAndBroadcast` checks expiry before starting `postPayment`, but it does not check again after the merchant round-trip completes. If the request expires while the POST is in flight, the code proceeds directly to `wallet.broadcast(prepared)`, so an expired payment request can still be broadcast.
In `DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/ExternalSendFlow.swift:302-320: Discard preparations abandoned by navigation
`openConfirm` now builds and signs while Send remains interactive. If the user opens Select source, presses Back, or otherwise changes the flow while `confirm.start()` is suspended, the post-await guard returns without calling `confirm.cancel()` or `recorder.discard` on a successful preparation. For BIP70 this leaves the confirmation's single-use claim held even though no POST or broadcast occurred; the next attempt with the same request can fail as already sent. Give preparation explicit cancellation/generation ownership and discard any result that no longer belongs to the active Send state.
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.
- Update the top-up compatibility harness when integrating current develop — The exact reviewed head does not contain
scripts/test_identity_top_up_compatibility.py, so the extracted helper cannot fail that absent script in this tree. Current develop adds the harness after this branch diverged, and its extraction marker/scaffold must be updated during integration because it still expects the old private helper declaration.- Follow-up: #1254
|
This PR is being split into a stack so each part can be reviewed on its own (merge in order):
The open review findings from this PR are fixed in the stack; I'll answer them here when this branch is rebuilt. |
c513181 to
d7ba75c
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (queue backlog)
Changes requested: 7 blockers
- The merge candidate pins an intermediate SDK commit from an open Platform PR —
.platform-ref:1(new; not shown inline, see below)
Impact: Merging this head would put the new money-moving routes on a development-only SDK revision rather than the selected integration revision. - Platform Max can pay more than Confirm showed —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:674-682(new; not shown inline, see below)
Impact: A holder sending Platform Max to someone else's Core address can send newly received credits that were not part of the confirmed amount. - Identity-to-Shielded says “Sent” while the payment is still unresolved —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:774(new; not shown inline, see below)
Impact: A holder can receive a success message for an external Shielded payment before the SDK has established that the recipient's note exists. - A Core payment link can be underpaid when the holder chooses Shielded —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:647-653(new; not shown inline, see below)
Impact: On protocol 14, a holder who confirms a prefilled Core payment from Shielded can send less than the link requests and leave the payment short. - Identity-to-Shielded Max can dip into the DashPay reserve —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:756-764(new; not shown inline, see below)
Impact: A holder who taps Max can finish with less than the promised DashPay reserve if the identity balance falls before confirmation. - A missing identity balance tells the holder not to retry a payment that never started —
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:146-152(new; not shown inline, see below)
Impact: A holder whose identity balance is not yet available from Platform can see “Send in progress” with no Retry even though nothing was signed or sent. - Update the top-up compatibility harness for the extracted helper —
DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift:716-720(carried)
Impact: The simulator CI job cannot compile the compatibility harness and never reaches the app's XCTest suite.
New on this head: This revision carries SDK Shielded spend plans through Confirm, enables Platform top-ups to other identities and Identity payments to external Shielded addresses, and moves identity lookups off the main actor. At d7ba75c40, simulator CI stopped before XCTest; recovery, workflow lint, test-target membership, and accessibility checks passed, and the head conflicts with base tip b0ff0ad0. Three verified suggestions are omitted under the comment budget.
A pattern across this PR's review rounds
This is review round 4, and the PR has drawn 20 blocking findings so far. 10 of them share 3 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.
1. Confirm does not bind the spend (4 new in this round, 2 earlier finding(s))
For routed credit sends, PreparedExternalSend does not consistently carry the approved payout and spending limits into the call that signs. The Shielded planner in the still-open Platform PR #5865 preserves the native-credit amount and binds note selection and fees, but prepareShielded passes the requested payout as a gross withdrawal reserve. Platform Max still calls withdrawAllToCore to plan again from a fresh balance, and Identity-to-Shielded checks amount plus fee without carrying the DashPay reserve into the spend.
Already tracked: dashpay/platform#5698
In this round: The merge candidate pins an intermediate SDK commit from an open Platform PR; Platform Max can pay more than Confirm showed; A Core payment link can be underpaid when the holder chooses Shielded; Identity-to-Shielded Max can dip into the DashPay reserve
2. Send status is inferred from SDK returns (2 new in this round finding(s))
SendOutcome and identityShieldOutcome infer whether a payment left the wallet from separate error-code lists, so a new pre-signing refusal can fall through to In progress. The reverse happens on a normal return from shieldedShieldFromIdentityToRecipient: the app says Sent even though the SDK has proved only the source balance and leaves that payment pending until the scan sees its note commitments.
Already tracked: dashpay/platform#5926
In this round: Identity-to-Shielded says “Sent” while the payment is still unresolved; A missing identity balance tells the holder not to retry a payment that never started
3. Recovery harnesses mirror production interfaces (2 earlier finding(s))
The drain and identity top-up harnesses compile selected production code against hand-written stand-ins, and the top-up harness also locates declarations by literal source markers. A change to the drain confirmation initializer or a move from the view model into IdentityCreditsTopUp requires a matching change in the harness before simulator CI can reach the app tests.
Suggested decision (land the prerequisite first): Make merged SwiftDashSDK support for executing the approved spend or refusing before signing a prerequisite for enabling each affected send mode. The signing call must honor the recipient payout and any Max spending limit, including the DashPay reserve; another balance read is not that guarantee. Land the required SDK support upstream first and pin the merged revision, or leave the modes it cannot yet support out of this PR. Platform #5865 supplies the Shielded note plan, not the corresponding guarantee for Platform or Identity Max.
🔴 7 blocking | 🟡 2 suggestion(s)
9 finding(s) not shown inline (GitHub refused the PR diff as too large)
🔴 Blocking: Update the top-up compatibility harness for the extracted helper
Impact: The simulator CI job cannot compile the compatibility harness and never reaches the app's XCTest suite.
DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift:716-720
The extractor now includes IdentityCreditsTopUp, but the harness's ManagedPlatformWallet implements only topUpFromAddresses. Swift checks the new external branch even though the existing harness tests do not call it. Exact-head Actions run 45162754211, job 137655842180, stops with value of type 'ManagedPlatformWallet' has no member 'topUpExternalIdentityFromAddresses', before any locale assertion can run. Add the matching SDK method to the fake and make the harness distinguish the managed and external paths.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
🔴 Blocking: The merge candidate pins an intermediate SDK commit from an open Platform PR
Impact: Merging this head would put the new money-moving routes on a development-only SDK revision rather than the selected integration revision.
.platform-ref:1
The project’s Platform release-pin rule makes temporary integration revisions development-only, and this PR explicitly requires the merged v5.2-dev pin before merge. The file still selects 7e46f99648; dashpay/platform#5865 is open and its head has moved past that commit. Once the binding lands, pin a selected merged revision containing all three APIs and validate that exact app/SDK pair, including the funded sends listed in the PR.
Confirmed by an independent pass: The Platform release-pin rule makes temporary integration revisions development-only and requires the SDK changes to be upstreamed. This merge candidate still pins 7e46f99648 from open Platform PR #5865 rather than a selected upstream revision containing the required APIs.
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
🔴 Blocking: Platform Max can pay more than Confirm showed
Impact: A holder sending Platform Max to someone else's Core address can send newly received credits that were not part of the confirmed amount.
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:674-682
The new Confirm-time check compares the displayed amount with one preflight, not with the withdrawal that gets signed. When a holder confirms Platform Max, performPlatformWithdraw(fullBalance: true) then calls withdrawAllToCore without the approved amount or inputs. At the pin, AUTO withdrawal calls plan_withdrawal again and signs from that fresh on-chain balance read. If a funded address receives credits between the two reads, the later plan includes them without another approval check. Execute the approved plan or have the SDK enforce the approved payout before signing and return to Send if it changes.
Confirmed by an independent pass: A holder confirms a Platform-to-Core Max send, and an incoming payment credits an already funded Platform address after the Confirm-time preflight reads its balance. The SDK's AUTO withdrawal reads the balance again and signs using the larger amount, paying more than Confirm showed without asking the holder to approve it.
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
🔴 Blocking: Identity-to-Shielded says “Sent” while the payment is still unresolved
Impact: A holder can receive a success message for an external Shielded payment before the SDK has established that the recipient's note exists.
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:774
After a holder confirms the new route, a normal return from shieldedShieldFromIdentityToRecipient becomes .sent and closes the flow with a success toast. At the pin, Rust returns normally after verifying an affected-state balance proof for the source identity. The verifier does not bind that proof to the submitted payment, and Rust explicitly leaves the activity pending until the Shielded scan observes the note commitments. Report .inFlight for that return and reserve .sent for evidence tied to the payment.
Confirmed by an independent pass: A holder confirms an Identity-to-Shielded payment, and the SDK can return normally after receiving a valid source-identity balance proof that does not establish that this payment executed. The app closes Send with a “Sent” toast even though the recipient note may not have been created and the SDK still treats the payment as pending.
return failure.map(Self.identityShieldOutcome) ?? .inFlight
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
🔴 Blocking: A Core payment link can be underpaid when the holder chooses Shielded
Impact: On protocol 14, a holder who confirms a prefilled Core payment from Shielded can send less than the link requests and leave the payment short.
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:647-653
Opening a plain dash: link with an amount prefills the requested recipient amount, and Send allows a funded Shielded source. The new checked planner passes that value to Rust as .exact, which means a gross withdrawal reserve, not an exact payout. At the app's 1 duff/byte rate on protocol 14, a 2,000,000-duff request plans a 1,999,810-duff payout. Confirm displays the reduced amount but does not identify it as short of the request or prevent that exact plan from running. Plan for the requested payout or refuse the route if the planned recipient amount differs; keep gross-reserve semantics for Max.
Confirmed by an independent pass: A holder opens a plain Core dash: link requesting 2,000,000 duffs, leaves the prefilled amount unchanged, and chooses a funded Shielded source on protocol 14. The planner treats that amount as the gross withdrawal reserve, so Confirm offers a 1,999,810-duff payout without flagging that it falls short of the request; approving it leaves the requested payment underpaid.
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
🔴 Blocking: Identity-to-Shielded Max can dip into the DashPay reserve
Impact: A holder who taps Max can finish with less than the promised DashPay reserve if the identity balance falls before confirmation.
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:756-764
Send computes Identity Max by subtracting the fee and reserve. If another identity operation spends credits before Confirm, the new dispatch check still admits the old Max whenever the remaining balance covers just the amount plus the estimated fee. Rust checks a proved balance before arming the debit guard, but its admission check covers the amount and protocol fee, not the app's DashPay reserve. Keep the base tip's Max-versus-typed distinction at preparation and enforce it again at dispatch against a current balance for the prepared identity. A Max that would dip into the reserve needs a fresh quote; a typed amount can still proceed with the warning. Do not treat the local snapshot as a proved balance or replace the reserve check with Rust's solvency check alone.
Confirmed by an independent pass: A holder selects Identity Max for an external Shielded payment, then another device using the same identity spends some credits before confirmation, leaving enough to cover the payment and fee but not enough to preserve the DashPay reserve. The original Max still executes, spending into credits the holder expected Max to leave for DashPay actions.
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
🔴 Blocking: A missing identity balance tells the holder not to retry a payment that never started
Impact: A holder whose identity balance is not yet available from Platform can see “Send in progress” with no Retry even though nothing was signed or sent.
DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:146-152
A Platform-funded top-up can pass the funding-address check even when the Current recipient has no proved balance entry yet, such as shortly after registration. The pinned SDK returns identityBalanceUnavailable (58) before signing in that case. The new Identity-to-Shielded call can return the same code before it signs or arms the debit guard if its local balance check passed but Platform returns no entry. Both mappings fall through to .inFlight, which closes Send and tells the holder not to send again. Treat code 58 as retryable and not sent at both operation boundaries, and keep ambiguous post-dispatch results in flight.
Confirmed by an independent pass: A holder confirms a funded Platform top-up to their Current identity, and a lagging Platform read returns no balance for that locally known identity. The SDK stops before signing, but the app closes Send with “Send in progress,” tells the holder not to retry, and offers no Retry even though nothing was submitted. The new Identity-to-Shielded route does the same if its local balance check passes but the SDK's proved balance read returns no entry.
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
🟡 Suggestion: A changed Shielded plan disables Continue even when the same amount still fits
Impact: A holder whose note selection changes during Confirm has to edit a still-valid amount or change sources before getting a new quote.
DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmViewModel.swift:174-178
Shielded sync can discover a note that changes selection without making the typed payment unaffordable. Rust refuses the old digest before reserving notes and can return a fresh selection, but Confirm converts the resulting .balanceChanged to .balanceNotEnough. confirmReportedNotEnough() then latches confirmRefusedAmount for non-Max amounts, so Continue stays disabled even after the balance refresh. Give stale plans a distinct return-to-Send reason that keeps the typed amount and permits a fresh plan and confirmation.
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
🟡 Suggestion: Topping up a non-Current identity in the same wallet leaves its balance stale
Impact: A holder with multiple identities can complete a Platform top-up to one they own and still see its old balance in the Identities list until a network refresh.
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:1328-1334
Switching the Current identity does not remove the other managed identities, but the new branch treats every non-Current recipient as foreign. The external SDK path signs with managed: false; send_signed_top_up reconciles the funding side but only persists the recipient balance for managed top-ups. The Identities list initially reads that persisted balance. Select the managed path by membership in the active wallet, and test Current, managed-but-not-Current, and foreign recipients separately.
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
Follow-up candidates (optional) (1)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: Confirm shows only one recipient for a BIP70 payment that pays several
Impact: A holder can confirm the full amount of a multi-output merchant request without seeing which other addresses receive that money.
DashWallet/Sources/UI/Payments/ExternalSend/Services/PaymentRequestFetching.swift:35-39
When a holder opens a verified BIP70 request with multiple valid outputs, PaymentRequestDetails supplies the first address and the sum of all the outputs. Expanding Confirm's To row adds the request URL, not the remaining recipients. This revision's amount and network checks still pass for that request, and buildForSend signs every verified output, so approving the payment can transfer funds to addresses the UI never showed. Show each verified output with its amount before Confirm, or refuse multi-output requests in this flow until it can display them.
source: gpt-6.2-astra (phase2-reviewer: general, ffi-engineer, security-auditor)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — ExternalSendExecutor.swift and ShieldedTransferCoordinator.swift change how funds move across multiple balance types by executing the SDK spend plan shown at confirmation, handling stale Shielded notes, and adding external Identity and Shielded send routes. - Phase 1 reviewers: not run (skipped for throughput: 33 PRs queued, above the 10 limit)
- New since the last final review (
c5131815): 7 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 6 confirmed, 1 not confirmed (no longer blocking) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): Confirm does not bind the spend; Send status is inferred from SDK returns; Recovery harnesses mirror production interfaces. When you fix the findings below, fix the cause, not only the reported case. The review suggests (land the prerequisite first): Make merged SwiftDashSDK support for executing the approved spend or refusing before signing a prerequisite for enabling each affected send mode. The signing call must honor the recipient payout and any Max spending limit, including the DashPay reserve; another balance read is not that guarantee. Land the required SDK support upstream first and pin the merged revision, or leave the modes it cannot yet support out of this PR. Platform #5865 supplies the Shielded note plan, not the corresponding guarantee for Platform or Identity Max. If that decision is not yours to make, say so to the PR's author or maintainer.
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift`:
- [BLOCKING] DashWallet/Sources/UI/DashPay/Profile/SDKIdentityProfileSheet.swift:716-720: Update the top-up compatibility harness for the extracted helper
Impact: The simulator CI job cannot compile the compatibility harness and never reaches the app's XCTest suite.
The extractor now includes `IdentityCreditsTopUp`, but the harness's `ManagedPlatformWallet` implements only `topUpFromAddresses`. Swift checks the new external branch even though the existing harness tests do not call it. Exact-head Actions run `45162754211`, job `137655842180`, stops with `value of type 'ManagedPlatformWallet' has no member 'topUpExternalIdentityFromAddresses'`, before any locale assertion can run. Add the matching SDK method to the fake and make the harness distinguish the managed and external paths.
In `.platform-ref`:
- [BLOCKING] .platform-ref:1: The merge candidate pins an intermediate SDK commit from an open Platform PR
Impact: Merging this head would put the new money-moving routes on a development-only SDK revision rather than the selected integration revision.
The project’s Platform release-pin rule makes temporary integration revisions development-only, and this PR explicitly requires the merged `v5.2-dev` pin before merge. The file still selects `7e46f99648`; `dashpay/platform#5865` is open and its head has moved past that commit. Once the binding lands, pin a selected merged revision containing all three APIs and validate that exact app/SDK pair, including the funded sends listed in the PR.
_Confirmed by an independent pass: The Platform release-pin rule makes temporary integration revisions development-only and requires the SDK changes to be upstreamed. This merge candidate still pins 7e46f99648 from open Platform PR #5865 rather than a selected upstream revision containing the required APIs._
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:674-682: Platform Max can pay more than Confirm showed
Impact: A holder sending Platform Max to someone else's Core address can send newly received credits that were not part of the confirmed amount.
The new Confirm-time check compares the displayed amount with one preflight, not with the withdrawal that gets signed. When a holder confirms Platform Max, `performPlatformWithdraw(fullBalance: true)` then calls `withdrawAllToCore` without the approved amount or inputs. At the pin, AUTO withdrawal calls `plan_withdrawal` again and signs from that fresh on-chain balance read. If a funded address receives credits between the two reads, the later plan includes them without another approval check. Execute the approved plan or have the SDK enforce the approved payout before signing and return to Send if it changes.
_Confirmed by an independent pass: A holder confirms a Platform-to-Core Max send, and an incoming payment credits an already funded Platform address after the Confirm-time preflight reads its balance. The SDK's AUTO withdrawal reads the balance again and signs using the larger amount, paying more than Confirm showed without asking the holder to approve it._
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:774: Identity-to-Shielded says “Sent” while the payment is still unresolved
Impact: A holder can receive a success message for an external Shielded payment before the SDK has established that the recipient's note exists.
After a holder confirms the new route, a normal return from `shieldedShieldFromIdentityToRecipient` becomes `.sent` and closes the flow with a success toast. At the pin, Rust returns normally after verifying an affected-state balance proof for the source identity. The verifier does not bind that proof to the submitted payment, and Rust explicitly leaves the activity pending until the Shielded scan observes the note commitments. Report `.inFlight` for that return and reserve `.sent` for evidence tied to the payment.
_Confirmed by an independent pass: A holder confirms an Identity-to-Shielded payment, and the SDK can return normally after receiving a valid source-identity balance proof that does not establish that this payment executed. The app closes Send with a “Sent” toast even though the recipient note may not have been created and the SDK still treats the payment as pending._
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:647-653: A Core payment link can be underpaid when the holder chooses Shielded
Impact: On protocol 14, a holder who confirms a prefilled Core payment from Shielded can send less than the link requests and leave the payment short.
Opening a plain `dash:` link with an amount prefills the requested recipient amount, and Send allows a funded Shielded source. The new checked planner passes that value to Rust as `.exact`, which means a gross withdrawal reserve, not an exact payout. At the app's 1 duff/byte rate on protocol 14, a 2,000,000-duff request plans a 1,999,810-duff payout. Confirm displays the reduced amount but does not identify it as short of the request or prevent that exact plan from running. Plan for the requested payout or refuse the route if the planned recipient amount differs; keep gross-reserve semantics for Max.
_Confirmed by an independent pass: A holder opens a plain Core `dash:` link requesting 2,000,000 duffs, leaves the prefilled amount unchanged, and chooses a funded Shielded source on protocol 14. The planner treats that amount as the gross withdrawal reserve, so Confirm offers a 1,999,810-duff payout without flagging that it falls short of the request; approving it leaves the requested payment underpaid._
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:756-764: Identity-to-Shielded Max can dip into the DashPay reserve
Impact: A holder who taps Max can finish with less than the promised DashPay reserve if the identity balance falls before confirmation.
Send computes Identity Max by subtracting the fee and reserve. If another identity operation spends credits before Confirm, the new dispatch check still admits the old Max whenever the remaining balance covers just the amount plus the estimated fee. Rust checks a proved balance before arming the debit guard, but its admission check covers the amount and protocol fee, not the app's DashPay reserve. Keep the base tip's Max-versus-typed distinction at preparation and enforce it again at dispatch against a current balance for the prepared identity. A Max that would dip into the reserve needs a fresh quote; a typed amount can still proceed with the warning. Do not treat the local snapshot as a proved balance or replace the reserve check with Rust's solvency check alone.
_Confirmed by an independent pass: A holder selects Identity Max for an external Shielded payment, then another device using the same identity spends some credits before confirmation, leaving enough to cover the payment and fee but not enough to preserve the DashPay reserve. The original Max still executes, spending into credits the holder expected Max to leave for DashPay actions._
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:1328-1334: Topping up a non-Current identity in the same wallet leaves its balance stale
Impact: A holder with multiple identities can complete a Platform top-up to one they own and still see its old balance in the Identities list until a network refresh.
Switching the Current identity does not remove the other managed identities, but the new branch treats every non-Current recipient as foreign. The external SDK path signs with `managed: false`; `send_signed_top_up` reconciles the funding side but only persists the recipient balance for managed top-ups. The Identities list initially reads that persisted balance. Select the managed path by membership in the active wallet, and test Current, managed-but-not-Current, and foreign recipients separately.
In `DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Domain/SendOutcome.swift:146-152: A missing identity balance tells the holder not to retry a payment that never started
Impact: A holder whose identity balance is not yet available from Platform can see “Send in progress” with no Retry even though nothing was signed or sent.
A Platform-funded top-up can pass the funding-address check even when the Current recipient has no proved balance entry yet, such as shortly after registration. The pinned SDK returns `identityBalanceUnavailable` (58) before signing in that case. The new Identity-to-Shielded call can return the same code before it signs or arms the debit guard if its local balance check passed but Platform returns no entry. Both mappings fall through to `.inFlight`, which closes Send and tells the holder not to send again. Treat code 58 as retryable and not sent at both operation boundaries, and keep ambiguous post-dispatch results in flight.
_Confirmed by an independent pass: A holder confirms a funded Platform top-up to their Current identity, and a lagging Platform read returns no balance for that locally known identity. The SDK stops before signing, but the app closes Send with “Send in progress,” tells the holder not to retry, and offers no Retry even though nothing was submitted. The new Identity-to-Shielded route does the same if its local balance check passes but the SDK's proved balance read returns no entry._
In `DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmViewModel.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Confirm/ConfirmViewModel.swift:174-178: A changed Shielded plan disables Continue even when the same amount still fits
Impact: A holder whose note selection changes during Confirm has to edit a still-valid amount or change sources before getting a new quote.
Shielded sync can discover a note that changes selection without making the typed payment unaffordable. Rust refuses the old digest before reserving notes and can return a fresh selection, but Confirm converts the resulting `.balanceChanged` to `.balanceNotEnough`. `confirmReportedNotEnough()` then latches `confirmRefusedAmount` for non-Max amounts, so Continue stays disabled even after the balance refresh. Give stale plans a distinct return-to-Send reason that keeps the typed amount and permits a fresh plan and confirmation.
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.
- Headless BIP70 can release signed bytes after a gift-card request expires — The existing headless caller captures
nowbefore authorization and passes it through fetch, signing, and the pre-POST check. If the request expires during those waits, the post-ACK check can prevent local broadcast but cannot retract bytes already sent to the merchant.- Follow-up: Use the injected clock immediately before handing off the signed transaction in the headless flow, and cover expiry during authorization and signing.
|
Split by route, each in its own PR once its Platform changes merge:
This PR stays a draft as the reference for those parts and will be closed when the last one is open. |
d7ba75c to
41479bd
Compare
41479bd to
e822c7d
Compare
e822c7d to
dbd8e7c
Compare
…plan Continue plans a Shielded transfer, unshield, withdrawal or identity top-up with `shieldedPlanSpend` for the exact credits (a Max's carried sweep credits), and Confirm shows the plan's fee as exact. Confirm runs the same plan; notes that moved since are refused by the SDK with nothing reserved and send the holder back to Send, which plans Max again. A withdrawal is planned and run at one Core fee rate. Confirm shows what the recipient receives after the Core fee, which the fee line carries. An amount outside Platform's withdrawal bounds is not sent. The Send screen's Shielded Max is the SDK's sweep plan, so a withdrawal's Max respects the largest withdrawal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The pair policy routes the Identity source to a Shielded address as the new identityToShielded route: its fee is an estimate that does not depend on the amount, and its Max is the identity's credits less that fee and the DashPay reserve. The pair stays unavailable, each with its own reason, when the wallet has no bound Shielded account (read from the manager's shieldedDefaultAddress, as the Shielded receive address reads it) and when the destination is the wallet's own Shielded address. The old "not supported yet" reason and its string are gone. The fee estimate of the route is unavailable for now, so Send cannot continue on it until the recipient shield is wired. SDD-Task: T133 SDD-AC: AC-06 SDD-AC: AC-09 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… address The identityToShielded route now runs shieldedShieldFromIdentityToRecipient from the Current identity at Shielded account 0, with no memo, signed by KeychainSigner inside the authorization given on Continue. Its fee is the identity shield's admission floor for two actions, in credits, which the charged fee never exceeds; Confirm shows it as "~". Right before the shield the executor reads the identity's credits again and refuses the send unless they cover the amount and the fee, so a short balance never arms the SDK's identity-debit guard. The route classifies the shield's errors with its own map: a debit still pending is "earlier payment pending", an unavailable signing key and a short balance keep their reasons, invalid input and recovery errors are not sent, and an unconfirmed shield or any other error is in flight with no Retry. Other routes keep the shared mapping. A balance that is not enough at Confirm sends the holder back to Send, as a changed Shielded plan does. SDD-Task: T134 SDD-AC: AC-06 Co-Authored-By: Claude Opus 5.5 <[email protected]>
dbd8e7c to
e859ec2
Compare
Issue being fixed or feature implemented
Part 5 of the new Send flow (MO-1121, Android parity with dash-wallet#1680). Stacked on #1501 (← #1423 ← #1502 ← #1409 ← #1407 ← #1406); the diff shows only this part. Rebuilt on 2026-11-26 onto the current stack; the Platform → someone else's identity work moved to #1502. It turns on the credit routes that need SDK changes from dashpay/platform: #5860 and #5863 (merged into
v5.2-dev) and #5865 (open).Summary, acceptance criteria and known limits of the whole feature:
docs/features/external-send/README.md.What was done?
shieldedPlanSpend, feat(platform-wallet): plan a shielded spend with its exact fee and spend against the plan platform#5865): Continue plans a Shielded transfer, unshield, withdrawal or identity top-up for the exact credits, Confirm shows the plan's fee as exact and runs the same plan. Notes that moved since are refused with nothing reserved and send the holder back to Send. A withdrawal amount outside Platform's bounds for its Core fee is not sent.shieldedShieldFromIdentityToRecipient, #5863): offered with its own reasons when unavailable (no bound Shielded account, the wallet's own Shielded address); fee shown as "~"; the identity's credits are read again right before the shield..platform-ref→985d2454f8(#5865's head, development only). Moves tov5.2-devonce #5865 merges.Next in the stack: #1519 (Core → someone else's identity or Platform address).
How Has This Been Tested?
dashwallet-dashpay, Debug, iPhone 17 simulator, against the pinned platform: 3605 tests, 1 skipped, 1 failure — the locale checkString_DashWallet.testAssumptionThatCurrencySymbolIsEitherAtTheBeginningOrAtTheEnd, which fails the same way on other branches with this Xcode and is untouched here.Unit tests: the SDK plan through Send/Confirm/executor, the external top-up route, code 80 → not sent, the off-main-actor lookup (a heartbeat during held reads), the Identity → Shielded pair policy and send
Maestro flows for the credit routes
A funded testnet send on each credit route
Breaking Changes
None in the app.
.platform-refpoints at a commit of an open platform PR (#5865); it must move tov5.2-devbefore this PR merges.Checklist:
🤖 Generated with Claude Code