Repository navigation
feat(wallet): send services, asset-lock recovery and payment-request checks - #1407
romchornyi wants to merge 1 commit into
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit b21f18d) · triage: critical |
a1fa579 to
3669dd2
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The PR introduces six blocking correctness or security issues in external-send and BIP70 lifecycle handling: prepared sends are not bound to the authorized wallet/network, Platform recipient networks are not validated, BIP70 expiry uses a stale timestamp, and ambiguous or consumed sends can remain retryable. Four additional suggestions cover fail-closed recovery, blocking identity FFI, legacy BIP70 error propagation, and expiry error classification. Three lower-priority valid suggestions were omitted to stay within the 10-finding budget; CI shows no failed build/test/lint check, while one title-policy check failed and two checks remain queued.
🔴 6 blocking | 🟡 4 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Preserve post-ACK in-flight status across the Objective-C bridge
DashWallet/Sources/UI/Payments/PaymentModels/BIP70InteractiveCoordinator.swift:105-110
BIP70Error.failedAfterAcknowledgement is correctly classified as .inFlight by the new Swift send outcome, but the legacy bridge maps every BIP70 error to the same generic NSError code. PaymentController.shouldReenableSending therefore re-enables Confirm for a post-ACK failure, and the user-facing error loses the transaction hash and non-retryable status needed for recovery. Add an Objective-C-visible code/status and preserve the tx hash, then make the legacy consumer keep the confirmation disabled for this outcome.
source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff is large and intricate and changes funds-movement paths in ExternalSendExecutor, CoreFundingResumer, ShieldedTransferCoordinator, WalletSendService, and related asset-lock recovery and transaction-sending code. - 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— 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/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:322-339: Bind the prepared BIP70 amount to the verified request
`preparePaymentRequest` builds and signs from `verified.confirmation.amount`, but stores and balance-checks the caller-provided `amount`. Those values are not enforced to match, so a stale or mismatched caller amount can make Confirm display one amount while the signed transaction sends another. The prepared model must use the verified request amount, or reject the preparation when the values differ.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:282-285: Treat a consumed prepare as in-flight, not retryable
`takePlan()` consumes the single-use plan before execution. A second Confirm activation therefore enters `case nil` and returns `.notSent(.failed)`, even though `SendOutcome` documents that only `notSent` offers Retry. A double tap or re-entry after the first send must fail closed as `.inFlight`, because the original operation may already have handed funds to a network or merchant.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:378-411: Bind prepared routed sends to the authorized wallet and network
`PreparedExternalSend` stores the route, destination, amount and fee, but not the wallet ID or active network captured during preparation. Routed sends authenticate and calculate their plan on Continue, then resolve the live Platform/SDK environment only when Confirm calls `runRouted`. A wallet switch or network change between those steps can therefore spend the newly active wallet without reauthorizing that context, and can carry a destination parsed under the old network into the new environment. Capture the preparation context and reject execution unless both wallet and network still match immediately before dispatch.
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:365-373: Preserve BIP70 expiry instead of mapping it to fee unavailable
`preparationError` maps every non-`WalletSendService` error to `.feeUnavailable`. When `buildForSend` rejects an expired verified request, a missing payment URL, or a network-related BIP70 condition, the external-send layer loses the reason and presents the generic fee-unavailable path. In particular, an expired request can be sent through a retry path that attempts to prepare the same stale confirmation instead of returning the user to request entry. Add distinct external-send preparation errors for these BIP70 cases and map them explicitly.
In `DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift`:
- [BLOCKING] DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:349-359: Do not release the BIP70 guard after an ambiguous POST failure
Any `postPayment` error resets `sendGuard`, although a transport failure cannot establish that the merchant did not receive the signed Payment bytes. The merchant may have stored or broadcast the first transaction while the user retries and builds a conflicting second payment. This path must retain the single-use claim and classify the result as in-flight unless the transport provides a proof that no request bytes were transmitted.
- [BLOCKING] DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:281-285: Use a fresh expiry timestamp after building the transaction
`confirmAndSend` captures its default `now` before the asynchronous build and passes that same value to `postAndBroadcast`; the headless path captures it even before authentication and request fetching. If the request expires during those operations, the pre-POST check still sees the old time. A request without `payment_url` can then be broadcast after expiry, while a request with `payment_url` can post expired signed bytes before the ACK-side `clock()` check. Read the injectable clock again after build and before entering the POST/broadcast phase.
In `DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift`:
- [BLOCKING] DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:924-926: Reject Platform destinations from the wrong network before funding
`parsePlatformRecipient` accepts both `dash` and `tdash` HRPs but returns only the address type and hash. `fundExternalFromCore` then discards the HRP and passes the hash to `resolveFundEnvironment` without comparing it to `env.network`. The UI parser's network check is not an independent guarantee for this public irreversible funding boundary: a direct or future caller can fund a valid address hash on the wrong Platform network and strand the asset lock. Preserve the decoded network/HRP and reject it against `runningNetwork` before building the Core lock.
- [SUGGESTION] DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:982-991: Treat an unavailable recipient check as unknown
`checkFundFromCoreResumable` returns normally when `modelContainer` is nil, even though it has not inspected either the recipient record or the asset-lock row. `TxDetailModel.recoveryKnowsRecipient` interprets that normal return as proof that the recipient is known and can expose Retry during startup or teardown. The check must throw or return an explicit unknown result when the container is unavailable so recovery remains fail-closed.
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Services/IdentityLookupService.swift:73-80: Do not run blocking identity FFI on the main actor
The live reader hops to the main actor to obtain `SDK`, and the SDK's `identityGet` and `dpnsGetUsername` methods are actor-isolated synchronous FFI bodies. The Swift methods are declared async but call Rust directly before any suspension; the Rust implementations use `runtime.block_on` for DAPI requests. Consequently, an identity lookup can block the main thread for the entire network operation and freeze the UI. The SwiftDashSDK wrapper should expose non-main-actor asynchronous query methods or move the synchronous FFI invocation onto its worker executor; wrapping this app call in another detached task is insufficient while the SDK methods remain main-actor isolated.
In `DashWallet/Sources/UI/Payments/PaymentModels/BIP70InteractiveCoordinator.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/PaymentModels/BIP70InteractiveCoordinator.swift:105-110: Preserve post-ACK in-flight status across the Objective-C bridge
`BIP70Error.failedAfterAcknowledgement` is correctly classified as `.inFlight` by the new Swift send outcome, but the legacy bridge maps every BIP70 error to the same generic NSError code. `PaymentController.shouldReenableSending` therefore re-enables Confirm for a post-ACK failure, and the user-facing error loses the transaction hash and non-retryable status needed for recovery. Add an Objective-C-visible code/status and preserve the tx hash, then make the legacy consumer keep the confirmation disabled for this outcome.
| txHashDisplay: prepared.txHashDisplay, | ||
| reason: (error as? BIP70Error)?.errorDescription ?? error.localizedDescription) |
There was a problem hiding this comment.
⏭️ Deferred (maintainer decision; not blocking) at
6ef91992; see the replies below.
🔴 Blocking: Do not release the BIP70 guard after an ambiguous POST failure
Any postPayment error resets sendGuard, although a transport failure cannot establish that the merchant did not receive the signed Payment bytes. The merchant may have stored or broadcast the first transaction while the user retries and builds a conflicting second payment. This path must retain the single-use claim and classify the result as in-flight unless the transport provides a proof that no request bytes were transmitted.
| txHashDisplay: prepared.txHashDisplay, | |
| reason: (error as? BIP70Error)?.errorDescription ?? error.localizedDescription) | |
| } catch { | |
| // The transport cannot prove that the merchant did not receive the signed bytes. | |
| throw BIP70Error.paymentNotAcknowledged( | |
| txHashDisplay: prepared.txHashDisplay, | |
| reason: (error as? BIP70Error)?.errorDescription ?? error.localizedDescription) | |
| } |
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)
There was a problem hiding this comment.
Deferred to #1416. In the new Send a failed or unacknowledged POST is reported in progress with no Retry (testPaymentRequestPostOrAckFailureIsInFlightNeverNotSent); the guard reset is the existing Confirm's documented caveat, which this PR only moved.
There was a problem hiding this comment.
Deferred (re-reviewed at 6ef91992): The existing BIP70 Confirm path still resets its guard after an ambiguous POST failure, but the new external-send path maps POST/ACK uncertainty to in flight and does not offer Retry. The existing guard and bridge correction is tracked in #1416.
| func confirmAndSend(_ confirmation: Confirmation, | ||
| now: Date = Date(), | ||
| awaitAcceptance: Bool = true) async throws -> SendResult { | ||
| let built = try await buildForSend(confirmation, now: now) | ||
| return try await postAndBroadcast(built, now: now, awaitAcceptance: awaitAcceptance) |
There was a problem hiding this comment.
⏭️ Deferred (maintainer decision; not blocking) at
6ef91992; see the replies below.
🔴 Blocking: Use a fresh expiry timestamp after building the transaction
confirmAndSend captures its default now before the asynchronous build and passes that same value to postAndBroadcast; the headless path captures it even before authentication and request fetching. If the request expires during those operations, the pre-POST check still sees the old time. A request without payment_url can then be broadcast after expiry, while a request with payment_url can post expired signed bytes before the ACK-side clock() check. Read the injectable clock again after build and before entering the POST/broadcast phase.
| func confirmAndSend(_ confirmation: Confirmation, | |
| now: Date = Date(), | |
| awaitAcceptance: Bool = true) async throws -> SendResult { | |
| let built = try await buildForSend(confirmation, now: now) | |
| return try await postAndBroadcast(built, now: now, awaitAcceptance: awaitAcceptance) | |
| let built = try await buildForSend(confirmation, now: now) | |
| return try await postAndBroadcast(built, now: clock(), awaitAcceptance: awaitAcceptance) |
source: gpt-6.1-sol (phase2-reviewer: general)
There was a problem hiding this comment.
Deferred to #1416: the new Send checks expiry at the Confirm tap and again after the ACK; the stale now is in the existing Confirm and headless paths, which predate this PR.
There was a problem hiding this comment.
Deferred (re-reviewed at 6ef91992): The stale injected timestamp remains in the pre-existing BIP70 Confirm and headless paths, while the new external-send path adds its own expiry checks around the new flow. The tracked #1416 work owns refreshing the timestamp after asynchronous build/authentication.
| func fetchIdentity(id: String, network: WalletEnvironment.NetworkKind) async throws { | ||
| let sdk = try await Self.sdk(for: network) | ||
| _ = try await sdk.identityGet(identityId: id) | ||
| } | ||
|
|
||
| func username(forIdentity id: String, network: WalletEnvironment.NetworkKind) async throws -> String? { | ||
| let sdk = try await Self.sdk(for: network) | ||
| let usernames = try await sdk.dpnsGetUsername(identityId: id, limit: 1) |
There was a problem hiding this comment.
✅ Resolved at
44590251; see the replies below.
🟡 Suggestion: Do not run blocking identity FFI on the main actor
The live reader hops to the main actor to obtain SDK, and the SDK's identityGet and dpnsGetUsername methods are actor-isolated synchronous FFI bodies. The Swift methods are declared async but call Rust directly before any suspension; the Rust implementations use runtime.block_on for DAPI requests. Consequently, an identity lookup can block the main thread for the entire network operation and freeze the UI. The SwiftDashSDK wrapper should expose non-main-actor asynchronous query methods or move the synchronous FFI invocation onto its worker executor; wrapping this app call in another detached task is insufficient while the SDK methods remain main-actor isolated.
source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)
There was a problem hiding this comment.
Fixed upstream in dashpay/platform#5862 (identityGet and dpnsGetUsername run off the main actor); the app gets it with the platform pin bump in the last PR of this stack (#1358).
There was a problem hiding this comment.
Deferred (re-reviewed at 6ef91992): The app-side reader still obtains the SDK on the main actor and calls the synchronous FFI methods, but the required non-main-actor SDK implementation is the tracked platform change in dashpay/platform#5862 and will arrive with the later platform pin update.
There was a problem hiding this comment.
Resolved (re-reviewed at 44590251): The upstream change you cited is already in this head's pin, 6e113dc8: both lookups use the SDK worker queue through nonisolated methods, unlike the previous reviewed pin.
| private static func preparationError(_ error: Error) -> ExternalSendError { | ||
| let nsError = error as NSError | ||
| guard nsError.domain == WalletSendService.errorDomain else { return .feeUnavailable } | ||
| switch WalletSendService.ErrorCode(rawValue: nsError.code) { | ||
| case .authenticationCancelled: return .authenticationCancelled | ||
| case .authenticationFailed: return .authenticationFailed | ||
| case .initialRestoreSync: return .initialRestoreSync | ||
| default: return .feeUnavailable | ||
| } |
There was a problem hiding this comment.
⏭️ Deferred (maintainer decision; not blocking) at
6ef91992; see the replies below.
🟡 Suggestion: Preserve BIP70 expiry instead of mapping it to fee unavailable
preparationError maps every non-WalletSendService error to .feeUnavailable. When buildForSend rejects an expired verified request, a missing payment URL, or a network-related BIP70 condition, the external-send layer loses the reason and presents the generic fee-unavailable path. In particular, an expired request can be sent through a retry path that attempts to prepare the same stale confirmation instead of returning the user to request entry. Add distinct external-send preparation errors for these BIP70 cases and map them explicitly.
source: muse-spark-1.3-contributor (phase1-reviewer: general)
There was a problem hiding this comment.
Deferred to #1416: an expired request needs its own error and a refetch-or-end path on Confirm; nothing is sent meanwhile.
There was a problem hiding this comment.
Deferred (re-reviewed at 6ef91992): The BIP70 preparation mapping still collapses expiry and related request failures, but this is an existing Confirm/headless-path issue rather than a defect introduced by the new routed send. The tracked #1416 follow-up owns the distinct error and refetch-or-end behavior.
3669dd2 to
6ef9199
Compare
|
On Preserve post-ACK in-flight status across the Objective-C bridge (BIP70InteractiveCoordinator.swift:105-110, not inline): deferred to #1416. The bridge mapping every BIP70 error to code 1 predates this PR, and a re-tap after an ACK is refused as already sent, so nothing is paid twice; the fix (a distinct code, no re-enable, the transaction recorded) belongs with the other existing-Confirm items there. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The exact head passes the available unit-test, target-membership, recovery, accessibility, and workflow checks, but the new external-send services still contain blocking correctness and security gaps. Platform-to-Identity affordability does not match the execution planner, prepared routed sends are not bound to their authorized wallet/network, and several new Platform and Shielded transfer boundaries discard destination network identity before FFI execution.
🔴 5 blocking | 🟡 1 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Enforce the active network at Platform-credit transfer boundaries
DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:681-716
The new Platform-credit routes reach PlatformAddressSyncCoordinator.transfer, whose parsePlatformRecipient accepts both dash and tdash addresses but returns only the FFI address type and hash. The HRP network identity is discarded before ManagedPlatformAddressWallet.transfer signs and submits the transition. The identity-to-Platform route has the same loss through PlatformAddressCreditOutput, which converts either HRP into raw storage bytes without comparing it with the active network. The earlier destination parser is not an irreversible-transfer boundary: a stale prepared destination or a direct/future caller can still pass the other network's address to the active SDK. Validate the decoded network against the running network immediately before constructing the transfer output and signing.
source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)
Still open from earlier rounds (3)
- 🔴 Blocking: Bind prepared routed sends to the authorized wallet and network —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:413-415(thread) - 🔴 Blocking: Treat a consumed prepare as in-flight, not retryable —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:280-295(thread) - 🟡 Suggestion: Treat an unavailable recipient check as unknown —
DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:987-992(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This large, intricate diff changes funds movement and asset-lock recovery in ExternalSendExecutor, CoreFundingResumer, WalletSendService, and related Platform/SDK transaction paths. - 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 (
3669dd27): 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— 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/ExternalSendFeeEstimator.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendFeeEstimator.swift:109-112: Use the execution headroom when checking Platform-to-Identity affordability
The Platform-to-Identity estimate uses `IdentityTopUpViewModel.observedTopUpTransitionFeeCredits` (41,500,000 credits, or 41,500 duffs), and `ExternalSendExecutor.prepareRouted` uses that estimate in `requireFits` before allowing Continue. The actual `IdentityCreditsTopUp.fromPlatform` execution calls `PlatformPaymentIdentityFundingPolicy.makeInputs`, which requires the target amount plus `feeHeadroomCredits` (200,000,000 credits, or 200,000 duffs). A balance between amount + 41,500 duffs and amount + 200,000 duffs therefore passes preparation and authentication but fails during input planning, so the confirmation affordability result does not match the send that will execute. Use the policy headroom or a planner-backed preflight, and add coverage for a balance in that interval.
_Raised on code unchanged since the last review, and confirmed by an independent pass: A Platform-to-Identity send can pass preparation and authentication when the Platform balance covers amount plus 41,500 duffs but not amount plus 200,000 duffs; after confirmation, IdentityCreditsTopUp.fromPlatform calls makeInputs and throws PlanningError, so the send fails instead of executing._
In `DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift`:
- [BLOCKING] DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:681-716: Enforce the active network at Platform-credit transfer boundaries
The new Platform-credit routes reach `PlatformAddressSyncCoordinator.transfer`, whose `parsePlatformRecipient` accepts both `dash` and `tdash` addresses but returns only the FFI address type and hash. The HRP network identity is discarded before `ManagedPlatformAddressWallet.transfer` signs and submits the transition. The identity-to-Platform route has the same loss through `PlatformAddressCreditOutput`, which converts either HRP into raw storage bytes without comparing it with the active network. The earlier destination parser is not an irreversible-transfer boundary: a stale prepared destination or a direct/future caller can still pass the other network's address to the active SDK. Validate the decoded network against the running network immediately before constructing the transfer output and signing.
- [SUGGESTION] DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:987-992: Treat an unavailable recipient check as unknown
(carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1407#discussion_r4564957570)
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:613-615: Preserve shielded destination network identity before passing raw Orchard bytes
The new Shielded routes decode bech32m destinations and pattern-match only the `.shielded(raw43:)` form at the Core-to-Shielded and Shielded/Platform-to-Shielded boundaries. `DashAddressClassifier` also returns `isMainnet`, but these helpers discard it and pass only the raw 43-byte payload to the SDK. A destination encoded for the other network can therefore be accepted by a direct or stale caller and reach a manager bound to the active network with no network discriminator remaining at the FFI boundary. Require the decoded network to match the active runtime network before returning or passing the raw Orchard payload, including both `toShielded` and `shieldedRaw43` paths.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:413-415: Bind prepared routed sends to the authorized wallet and network
(carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1407#discussion_r4564957527)
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:280-295: Treat a consumed prepare as in-flight, not retryable
(carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1407#discussion_r4564957504)
6ef9199 to
bab3042
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The head still contains blocking correctness and security gaps at Platform-credit transfer boundaries, including wrong-network address acceptance and an identity-to-Platform path that strips the network before FFI marshaling. Its Platform-to-Identity fee estimate and Platform-to-Core affordability check also do not match execution, and own asset-lock recipient metadata is never persisted; simulator tests and the VoiceOver audit remain pending while the completed checks pass.
🔴 5 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Enforce the active network at Platform-credit transfer boundaries
DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:692-698
parsePlatformRecipient accepts both dash and tdash, but transfer only retains the raw address type and hash before calling the SDK. Because runningNetwork is not compared with the decoded HRP, the new Platform-to-Platform external-send route can submit a valid address from the other network after its network discriminator has been discarded. Validate the decoded network at this irreversible coordinator boundary, not only in the UI parser.
guard let decoded = DashAddressClassifier.decodeBech32m(destination),
decoded.isMainnet == (network == .mainnet),
let recipient = Self.parsePlatformRecipient(bech32m: destination)
else { throw SendError.invalidDestination }
guard recipient.ffiAddressType == 0
else { throw SendError.p2shNotSupported }
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)
Still open from earlier rounds (1)
- 🔴 Blocking: Use the execution headroom when checking Platform-to-Identity affordability —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendFeeEstimator.swift:109-112(thread)
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: Validate the recovery txid before constructing the SDK outpoint key
DashWallet/Sources/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift:289-290
CoreFundingRecipientCheck.recipient constructs the persistence key before calling the SDK resume wrapper. PersistentAssetLock.encodeOutPoint has a 36-byte precondition, so a malformed persisted record or direct caller supplying a txid other than 32 bytes crashes the process before the SDK wrapper can return its typed invalid-parameter error. Reject malformed txids with a fail-closed recovery error before appending the vout and encoding the outpoint.
guard outPointTxid.count == 32 else {
log("Asset lock outpoint txid has invalid length; not resumed")
throw CoreFundingResumer.ResumeError.recipientUnknown
}
let outPointHex = Self.outPointHex(txid: outPointTxid, vout: outPointVout)
source: gpt-6.1-sol (phase2-reviewer: ffi-engineer)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This large, intricate diff changes funds movement and transaction preparation/broadcasting in ExternalSendExecutor, CoreFundingResumer, ShieldedTransferCoordinator, WalletSendService, and SwiftDashSDKTransactionSender, including asset-lock recovery and SDK boundary interactions. - 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 (
6ef91992): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 2 confirmed; 1 new suggestion(s) listed as follow-up candidates, not posted inline - 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/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift`:
- [BLOCKING] DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:692-698: Enforce the active network at Platform-credit transfer boundaries
`parsePlatformRecipient` accepts both `dash` and `tdash`, but `transfer` only retains the raw address type and hash before calling the SDK. Because `runningNetwork` is not compared with the decoded HRP, the new Platform-to-Platform external-send route can submit a valid address from the other network after its network discriminator has been discarded. Validate the decoded network at this irreversible coordinator boundary, not only in the UI parser.
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:560-565: Check the selected Platform withdrawal source when validating affordability
`requireFits` compares the requested amount and fee with `LiveExternalSendBalances`' aggregate Platform balance. The eventual non-Max Platform-to-Core execution instead calls `withdrawToCore`, which selects the single highest-balance address and rejects unless that selected row alone covers the amount plus fee headroom. When funds are split across rows, preparation can therefore approve the send and authenticate the user even though the selected source cannot execute it. Use a withdrawal preflight or source-specific check for the exact execution path.
In `DashWallet/Sources/UI/Payments/InternalTransfer/IdentityWithdrawViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/InternalTransfer/IdentityWithdrawViewModel.swift:224-233: Reject wrong-network Platform addresses in Identity-to-Platform sends
`PlatformAddressCreditOutput.init(bech32mAddress:)` accepts either `dash` or `tdash` through `AddressTransformer.parseBech32mAddress`, then retains only the address type and hash. `LiveIdentityCreditsSend` uses this initializer for the new Identity-to-Platform external-send route, so the FFI receives no network discriminator and no active-network comparison occurs before the transfer. Require the decoded HRP to match `WalletEnvironment.isMainnet` before converting the address to raw bytes.
_Raised on code unchanged since the last review, and confirmed by an independent pass: A stale or directly constructed `Destination` containing a valid address for the other network can reach `LiveIdentityCreditsSend.run` because `ExternalSendExecutor` does not revalidate the destination network. `PlatformAddressCreditOutput` strips the HRP and sends the raw hash on the active network, potentially transferring credits to the wrong network's address._
In `DashWallet/Sources/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift`:
- [BLOCKING] DashWallet/Sources/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift:170-188: Persist Platform recipient metadata when an asset lock is built
The new production funding handlers persist only an external recipient record or an own mark in `UserDefaults`; they never assign `PersistentAssetLock.recipientPlatformAddressHash`, `recipientPlatformAddressType`, or `recipientIsExternal`. The SDK model documents these fields as caller-owned metadata, and `PlatformAddressActivityStore.matchesOwnAssetLockTopUp` uses the stored hash to recognize own Core-to-Platform top-ups. As a result, own top-ups created through this path lack the metadata needed for activity reconciliation, while the tests pass because they manually seed the fields. Persist the selected recipient hash, type, and external discriminator at the built/completed asset-lock boundary and preserve them across subsequent status upserts.
_Raised on code unchanged since the last review, and confirmed by an independent pass: A successful own Core-to-Platform top-up through `PlatformAddressSyncCoordinator.fundFromCore` leaves the new `PersistentAssetLock` row with nil recipient metadata. When the resulting Platform balance increase is reconciled, `matchesOwnAssetLockTopUp` cannot match the lock and records the wallet's own top-up as an external incoming activity, producing incorrect transaction history/reconciliation._
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendFeeEstimator.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendFeeEstimator.swift:109-112: Use the execution headroom when checking Platform-to-Identity affordability
(carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1407#discussion_r4567015459)
| func fundOwn( | ||
| lockValueDuffs: UInt64, platformAccountIndex: UInt32, | ||
| recipients: [ManagedPlatformAddressWallet.FundFromAssetLockRecipient], | ||
| onAssetLockBuilt: AssetLockBuiltHandler? | ||
| ) async throws -> [ManagedPlatformAddressWallet.UpdatedBalance] { | ||
| try await edge.fundOwn( | ||
| lockValueDuffs: lockValueDuffs, platformAccountIndex: platformAccountIndex, recipients: recipients, | ||
| onAssetLockBuilt: recipientStore.ownBuiltHandler(then: onAssetLockBuilt)) | ||
| } | ||
|
|
||
| func fundExternal( | ||
| record: ExternalFundingRecipientRecord, | ||
| lockValueDuffs: UInt64, platformAccountIndex: UInt32, | ||
| recipients: [ManagedPlatformAddressWallet.FundFromAssetLockRecipient], | ||
| onAssetLockBuilt: AssetLockBuiltHandler? | ||
| ) async throws -> [ManagedPlatformAddressWallet.UpdatedBalance] { | ||
| try await edge.fundExternal( | ||
| lockValueDuffs: lockValueDuffs, platformAccountIndex: platformAccountIndex, recipients: recipients, | ||
| onAssetLockBuilt: record.builtHandler(store: recipientStore, then: onAssetLockBuilt)) |
There was a problem hiding this comment.
⏭️ Deferred (maintainer decision; not blocking) at
96f53892; see the replies below.
🔴 Blocking: Persist Platform recipient metadata when an asset lock is built
The new production funding handlers persist only an external recipient record or an own mark in UserDefaults; they never assign PersistentAssetLock.recipientPlatformAddressHash, recipientPlatformAddressType, or recipientIsExternal. The SDK model documents these fields as caller-owned metadata, and PlatformAddressActivityStore.matchesOwnAssetLockTopUp uses the stored hash to recognize own Core-to-Platform top-ups. As a result, own top-ups created through this path lack the metadata needed for activity reconciliation, while the tests pass because they manually seed the fields. Persist the selected recipient hash, type, and external discriminator at the built/completed asset-lock boundary and preserve them across subsequent status upserts.
Raised on code unchanged since the last review, and confirmed by an independent pass: A successful own Core-to-Platform top-up through PlatformAddressSyncCoordinator.fundFromCore leaves the new PersistentAssetLock row with nil recipient metadata. When the resulting Platform balance increase is reconciled, matchesOwnAssetLockTopUp cannot match the lock and records the wallet's own top-up as an external incoming activity, producing incorrect transaction history/reconciliation.
source: gpt-6.1-sol (phase2-reviewer: general)
There was a problem hiding this comment.
Deferred: nothing in the app writes recipientPlatformAddress* on develop either, so own top-ups predate this PR in missing the match; it affects activity history only. Tracked in #1419.
There was a problem hiding this comment.
Deferred (re-reviewed at 96f53892): This remains a pre-existing activity-reconciliation gap: the current funding handlers still record recovery metadata without populating the PersistentAssetLock recipient fields used to match own top-ups. It is intentionally deferred to #1419.
bab3042 to
96f5389
Compare
|
Body finding at bab3042, fixed in 96f5389: Platform-credit transfer network (PlatformAddressSyncCoordinator.swift:692) — |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Three blocking issues remain on this head: the BIP70 built-send object is reusable after its first invocation, wallet/network context validation is vulnerable to ABA transitions during asynchronous preparation, and the new identity-credit routes reach SwiftDashSDK signer wrappers with unsafe lifetime handling. The CI snapshot reports DashWalletTests and all supporting code checks successful; only the separate review check remains in progress.
A pattern across this PR's review rounds
This is review round 4, and the PR has drawn 15 blocking findings so far. 15 of them share 4 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.
1. BIP70 execution state is split across unowned stages (1 new in this round, 4 earlier finding(s))
The BIP70 flow passes a confirmation, then a built transaction, then a POST and broadcast, but no single synchronized state machine owns the request amount, expiry, send claim, and consumed built value through all stages. Each fix adds another guard or timestamp to one stage while another caller can still reuse or reinterpret the same signed payment.
Already tracked: #1416
In this round: Make a built BIP70 send one-shot across postAndBroadcast
2. Prepared routed sends do not own the execution context (1 new in this round, 8 earlier finding(s))
ExternalSendExecutor records a value snapshot, while the live adapters independently resolve the wallet, network, source row, fee headroom, and decoded destination when execution begins. The prepared object therefore is not an immutable, network-bound execution plan: context can change during preparation, address network identity can be discarded, and the source or affordability calculation can differ from what executes.
Already tracked: #1271
In this round: Detect wallet or network changes that occur during asynchronous send preparation
3. Asset-lock recovery lacks complete durable recipient state (2 earlier finding(s))
Recovery depends on caller-maintained metadata beside the SDK asset-lock row, but production funding paths do not consistently persist that metadata and an unavailable store can be treated as proof that the recipient is known. Consequently, each new recovery path needs another special case instead of reading one durable, fail-closed record.
Already tracked: #1419
4. FFI ownership and execution placement are left to callers (1 new in this round, 1 earlier finding(s))
The identity services call SDK FFI through wrappers whose async signatures do not by themselves guarantee nonblocking execution or keep callback-backed signer objects alive. The app consequently has to patch actor hops and local signer keepalives independently, leaving the next identity call exposed to the same lifetime or scheduling defect.
In this round: Keep KeychainSigner alive across the new identity-credit FFI calls
Suggested decision (redesign the component): Redesign the prepared-send boundary before adding more route-specific patches. PreparedExternalSend and BIP70PaymentService need explicit synchronized lifecycle state, an immutable wallet/runtime lease and typed network-bound destination, and one route-specific source and fee plan that preparation and execution both use. The recovery and identity adapters must likewise own durable recipient metadata and signer/FFI lifetime instead of relying on caller conventions. Until those boundaries exist, stop extending this component and either remove the routes that cannot meet them or land the required lower-level ownership APIs first.
If a later review again finds new blockers from these causes, it will ask for that decision and pause automatic re-review until it is made.
🔴 3 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Make a built BIP70 send one-shot across postAndBroadcast
DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:323-352
buildForSend claims the confirmation's send guard, but BuiltSend has no independent consumed state and postAndBroadcast never claims or marks the built value as used. A caller that retains or concurrently invokes the same BuiltSend can therefore POST the identical signed Payment more than once; the duplicate merchant POST occurs before any underlying broadcast rejection, and awaitAcceptance == false can also launch multiple background broadcasts. Add a synchronized lifecycle state shared by copies of BuiltSend and atomically claim it at the beginning of postAndBroadcast; every expiry, POST, ACK, synchronous broadcast, and background-broadcast outcome must transition that state. Retryable pre-spend behavior should require a fresh build rather than reusing the signed object.
Raised on code unchanged since the last review, and confirmed by an independent pass: After one successful postAndBroadcast, a caller can invoke it again with the retained BuiltSend and POST and broadcast the same signed Payment a second time; concurrent calls can do so as well. A pre-spend expiry or POST failure is even explicitly reset on the shared Confirmation guard, allowing the same BuiltSend to be retried rather than requiring a fresh build.
source: gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This large, intricate diff changes funds movement and asset-lock recovery in ExternalSendExecutor, CoreFundingResumer, and related wallet transaction-spending paths. - 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 (
bab30421): 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— 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
Several findings on this PR share an underlying cause (the review's "pattern" section): BIP70 execution state is split across unowned stages; Prepared routed sends do not own the execution context; Asset-lock recovery lacks complete durable recipient state; FFI ownership and execution placement are left to callers. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Redesign the prepared-send boundary before adding more route-specific patches. PreparedExternalSend and BIP70PaymentService need explicit synchronized lifecycle state, an immutable wallet/runtime lease and typed network-bound destination, and one route-specific source and fee plan that preparation and execution both use. The recovery and identity adapters must likewise own durable recipient metadata and signer/FFI lifetime instead of relying on caller conventions. Until those boundaries exist, stop extending this component and either remove the routes that cannot meet them or land the required lower-level ownership APIs first. 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/Models/PaymentProtocol/BIP70PaymentService.swift`:
- [BLOCKING] DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:323-352: Make a built BIP70 send one-shot across postAndBroadcast
`buildForSend` claims the confirmation's send guard, but `BuiltSend` has no independent consumed state and `postAndBroadcast` never claims or marks the built value as used. A caller that retains or concurrently invokes the same `BuiltSend` can therefore POST the identical signed Payment more than once; the duplicate merchant POST occurs before any underlying broadcast rejection, and `awaitAcceptance == false` can also launch multiple background broadcasts. Add a synchronized lifecycle state shared by copies of `BuiltSend` and atomically claim it at the beginning of `postAndBroadcast`; every expiry, POST, ACK, synchronous broadcast, and background-broadcast outcome must transition that state. Retryable pre-spend behavior should require a fresh build rather than reusing the signed object.
_Raised on code unchanged since the last review, and confirmed by an independent pass: After one successful postAndBroadcast, a caller can invoke it again with the retained BuiltSend and POST and broadcast the same signed Payment a second time; concurrent calls can do so as well. A pre-spend expiry or POST failure is even explicitly reset on the shared Confirmation guard, allowing the same BuiltSend to be retried rather than requiring a fresh build._
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:322-355: Detect wallet or network changes that occur during asynchronous send preparation
`prepare` captures only the value-based `ExternalSendContext` before awaiting `prepareRoute`, then `send` accepts the plan when the current context has the same wallet ID and network. If the active wallet or network changes during preparation and changes back before dispatch, the equality check passes even though authentication, balance and fee checks, and route-specific preparation occurred under a different environment. The subsequent live wallet lookup only selects the environment used for dispatch; it does not bind the prepared work or finalized plan to the environment that was authorized. Capture a monotonic wallet/network lifecycle generation or an immutable environment token that is invalidated on every transition, and reject dispatch whenever that generation or token changes.
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:1045-1067: Keep KeychainSigner alive across the new identity-credit FFI calls
The new identity-credit route creates a `KeychainSigner` and reaches `withdrawCredits`, `transferCreditsToAddresses`, and `transferCredits`; the Platform-to-Identity route also reaches `topUpFromAddresses` through `IdentityCreditsTopUp`. In the pinned SwiftDashSDK, these wrappers extract `signer.handle`, pass the non-owning handle into the C ABI, and use only a bare `_ = signer` inside detached work. `KeychainSigner` registers its callback context with `Unmanaged.passUnretained(self)`, so the signer must remain alive through the entire synchronous FFI call. The sibling SDK source already documents that bare keepalives can be released under optimization and uses `withExtendedLifetime` in equivalent wrappers. Fix the owning SwiftDashSDK wrappers for all of these calls by wrapping the complete FFI invocation in `withExtendedLifetime(signer)`; retaining the signer in this app method cannot repair a wrapper that may release it before the callback finishes.
96f5389 to
889241b
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The exact reviewed head has successful unit-test, target-membership, accessibility, workflow, recovery, title, and CodeRabbit checks. Static review still finds blocking value-safety issues in shielded Max confirmation, identity-source binding, asset-lock recovery scoping, asynchronous preparation context validation, and the reusable BIP70 built-send API.
Step back: this PR keeps drawing new blockers
This is review round 5, and the PR has drawn 17 blocking findings so far. The review of 96f53892 named these causes and the decision that would settle it; this round found 2 more finding(s) from the same place. Fixing them one at a time is not converging, so this review asks for that decision before another round.
1. BIP70 lifecycle is still split across independently guarded stages (5 earlier finding(s))
BIP70 uses a confirmation guard, a built transaction, merchant POST, ACK handling, and broadcast as separate states, but no single synchronized lifecycle owns the claim through every outcome. Local fixes add expiry checks and error classifications while retry release, duplicate use, and post-ACK uncertainty remain decided by different stages.
Already tracked: #1416
2. Prepared sends are snapshots rather than immutable execution plans (2 new in this round, 10 earlier finding(s))
PreparedExternalSend records selected values but execution still resolves live wallet, network, identity, source rows, fee headroom, and decoded destinations later. The same gap appears in Max drain confirmation, where execution re-quotes a changing payout and accepts a lower result, so each route-specific patch discovers another value or identity that was not bound to the user's authorization.
Already tracked: #1271
In this round: Require the confirmed Max payout to remain unchanged before draining to an external shielded address; Bind prepared Identity-source sends to the identity authorized during preparation
3. Asset-lock recovery still depends on caller-side metadata (2 earlier finding(s))
Recovery has no single durable record containing the lock's recipient and ownership classification. Production paths write side metadata inconsistently, while an unavailable store or missing SDK-row metadata can leave recovery unable to distinguish an own top-up from an external payment, so every new resume path needs another fail-closed exception.
Already tracked: #1419
4. Identity FFI ownership remains a caller convention (2 earlier finding(s))
Identity reads and credit sends cross into synchronous or callback-backed FFI through wrappers whose async signatures do not own execution placement or signer lifetime. Callers therefore add separate actor hops and local keepalives, leaving the next identity operation exposed to the same scheduling or deallocation failure.
Requested decision (redesign the component): Redesign the send-execution boundary before adding more route-specific patches. ExternalSendExecutor and BIP70 need one synchronized lifecycle with an immutable, wallet/network/identity-bound execution plan carrying the exact destination, source, amount, fee, and Max payout that execution must use. The lower-level asset-lock and identity adapters must own durable recipient metadata and FFI signer/execution lifetime rather than relying on caller conventions. Until those properties exist, remove or gate routes that cannot provide them, or land the required lower-level ownership APIs first.
Automatic re-review is paused until then: later pushes keep this review's verdict and are not reviewed on their own. Comment @thepastaclaw review once the decision is made: that resumes automatic re-review, and reviews the current commit if it has not been reviewed.
🔴 4 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Require the confirmed Max payout to remain unchanged before draining to an external shielded address
DashWallet/Sources/UI/Payments/InternalTransfer/Shielded/ShieldedTransferCoordinator.swift:816-819
The external Core-to-Shielded Max recheck accepts any lower payout because it only verifies recipientCredits / creditsPerDuff <= confirmedDuffs. performWalletDrain then executes the newly quoted recipient amount, so a fee increase or eligible-balance decrease between Continue and Confirm can send less than the amount shown and confirmed by the user. The send-time check must require the same duff-denominated recipient amount that was confirmed, not merely an upper bound.
recipientCredits / PlatformPaymentIdentityFundingPolicy.creditsPerDuff == confirmedDuffs
source: gpt-6.1-sol (phase2-reviewer: general)
Still open from earlier rounds (1)
- 🔴 Blocking: Detect wallet or network changes that occur during asynchronous send preparation —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:322-325(thread)
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: Bind Core funding recovery to the wallet that owns the asset lock
DashWallet/Sources/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift:289-335
CoreFundingRecipientCheck.lockRow filters only by outPointHex, even though PersistentAssetLock stores walletId and the network-scoped SwiftData container can contain rows for multiple wallets. resumeFundFromCore resolves the currently active wallet and then uses that wallet's signer, Platform addresses, and remainder addresses. A stale recovery detail from wallet A can therefore be checked against A's row after switching to wallet B, then resumed with B's execution environment and caller-supplied recipients. Scope the row lookup and recipient metadata to the resolved wallet ID, and revalidate the wallet/network context before dispatch.
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); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff is large and intricate and changes funds-movement paths in ExternalSendExecutor, CoreFundingResumer, ShieldedTransferCoordinator, and transaction-sending services, including authentication, signing, asset-lock recovery, and broadcast behavior. - 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 (
96f53892): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed, 1 not confirmed (now follow-up candidates) - Fresh verifier:
gpt-6.1-sol— final-verifier; 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
Before fixing anything, read the review's "Step back" section. This PR keeps drawing new blocking findings from the same underlying causes, and patching the findings below one at a time is not converging. The review asks for this decision first (redesign the component): Redesign the send-execution boundary before adding more route-specific patches. ExternalSendExecutor and BIP70 need one synchronized lifecycle with an immutable, wallet/network/identity-bound execution plan carrying the exact destination, source, amount, fee, and Max payout that execution must use. The lower-level asset-lock and identity adapters must own durable recipient metadata and FFI signer/execution lifetime rather than relying on caller conventions. Until those properties exist, remove or gate routes that cannot provide them, or land the required lower-level ownership APIs first. Raise that decision with the PR's author or maintainer instead of only patching; if it is theirs to make, stop and ask them.
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/Models/PaymentProtocol/BIP70PaymentService.swift`:
- [BLOCKING] DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:323-359: Make a built BIP70 send one-shot across postAndBroadcast
`buildForSend` claims the confirmation's guard, but `postAndBroadcast` never atomically claims or consumes the returned `BuiltSend`. Because `BuiltSend` is copyable, a caller can invoke `postAndBroadcast` twice with the same signed transaction: both calls can POST the same Payment before the second reaches the native transaction's single-use broadcast handle. The outer `PreparedPaymentRequestSend` currently protects its own caller, but the extracted service boundary remains replayable and allows duplicate merchant-side processing, including during races or ambiguous first results. Add reference-backed single-use state to `BuiltSend` or otherwise claim execution before POST and retain that claim for every ambiguous outcome.
In `DashWallet/Sources/UI/Payments/InternalTransfer/Shielded/ShieldedTransferCoordinator.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/InternalTransfer/Shielded/ShieldedTransferCoordinator.swift:816-819: Require the confirmed Max payout to remain unchanged before draining to an external shielded address
The external Core-to-Shielded Max recheck accepts any lower payout because it only verifies `recipientCredits / creditsPerDuff <= confirmedDuffs`. `performWalletDrain` then executes the newly quoted recipient amount, so a fee increase or eligible-balance decrease between Continue and Confirm can send less than the amount shown and confirmed by the user. The send-time check must require the same duff-denominated recipient amount that was confirmed, not merely an upper bound.
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:1041-1059: Bind prepared Identity-source sends to the identity authorized during preparation
The prepared context binds only the wallet ID and network. For Identity-source routes, `LiveIdentityCreditsSend.spend` resolves `DWCurrentUserIdentityInfo.shared.refreshedSnapshot().identityId` only when Confirm dispatches. If the active identity changes after preparation, the send uses the newly selected identity even though its balance was not checked and it was not the identity presented for authorization. Capture the source identity during preparation and reject execution when it changes, or carry the captured identity ID through the prepared route to the sending seam.
_Raised on code unchanged since the last review, and confirmed by an independent pass: Prepare authenticates and checks the balance of identity A, but `LiveIdentityCreditsSend.spend` resolves `DWCurrentUserIdentityInfo.shared.refreshedSnapshot().identityId` again during Confirm. If the same wallet switches its main identity to B after preparation, the unchanged wallet/network context permits the send and the SDK spends the prepared amount from B instead of the identity that was checked and authorized._
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:322-325: Detect wallet or network changes that occur during asynchronous send preparation
(carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1407#discussion_r4569271418)
| @@ -320,6 +358,12 @@ final class BIP70PaymentService { | |||
| txHashDisplay: prepared.txHashDisplay, | |||
| reason: (error as? BIP70Error)?.errorDescription ?? error.localizedDescription) | |||
There was a problem hiding this comment.
⚖️ Disputed (left to the maintainers; not blocking) at
610e22d5; see the replies below.
🔴 Blocking: Make a built BIP70 send one-shot across postAndBroadcast
buildForSend claims the confirmation's guard, but postAndBroadcast never atomically claims or consumes the returned BuiltSend. Because BuiltSend is copyable, a caller can invoke postAndBroadcast twice with the same signed transaction: both calls can POST the same Payment before the second reaches the native transaction's single-use broadcast handle. The outer PreparedPaymentRequestSend currently protects its own caller, but the extracted service boundary remains replayable and allows duplicate merchant-side processing, including during races or ambiguous first results. Add reference-backed single-use state to BuiltSend or otherwise claim execution before POST and retain that claim for every ambiguous outcome.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, ffi-engineer, security-auditor)
There was a problem hiding this comment.
Not changing this: postAndBroadcast has two callers, confirmAndSend and LiveCorePaymentRequestSend.sendAction; each calls it once, and the latter runs only through the single-use PreparedPaymentRequestSend.send(). No live path can POST the same BuiltSend twice.
There was a problem hiding this comment.
The two current callers being one-shot does not make BIP70PaymentService.postAndBroadcast one-shot. A caller holding the same BuiltSend can invoke that service method concurrently twice: both calls pass the expiry check and can POST the identical signed Payment before either reaches broadcast. PreparedPaymentRequestSend.send() protects only the external wrapper; it cannot protect direct or future callers of the raw BuiltSend API, whose own comments say that postAndBroadcast consumes the claim but the method never claims or consumes it.
There was a problem hiding this comment.
Disputed (re-reviewed at 1ff8939e): We still disagree on this one, and my answer is above, so I'm leaving the call to the maintainers. It no longer blocks this pull request, and I won't raise it again unless a later change brings the problem back.
There was a problem hiding this comment.
Tracked as item 6 of #1416: postAndBroadcast will consume the built send itself, so no future caller can replay it. No live path calls it twice today.
There was a problem hiding this comment.
Disputed (re-reviewed at 610e22d5): The raw postAndBroadcast boundary remains replayable, but the maintainer has disputed carrying this identity and tracks the planned consuming change as item 6 of #1416. I am not reopening the settled disputed finding on this head.
889241b to
1ff8939
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Three blocking correctness issues remain at this head. External Shielded Max sends can execute with a changed payout, prepared sends use value equality rather than a transition-safe lifecycle binding, and the BIP70 post-and-broadcast boundary remains replayable even though current callers invoke it only once. The simulator test check is still in progress; no failed code check is present.
🔴 2 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Require the confirmed Max payout to remain unchanged before draining to an external shielded address
DashWallet/Sources/UI/Payments/InternalTransfer/Shielded/ShieldedTransferCoordinator.swift:1260-1263
The external Max drain still accepts a changed, smaller payout. drainConfirmation permits the fresh recipient quote when recipientCredits / 1000 <= confirmedDuffs, and drainStillMatches permits a lower candidate balance with the same <= comparison. The SDK drain then recomputes the eligible notes and payout without receiving the confirmed amount as an execution cap, so a balance or fee change while Confirm is open can send a different amount than the user authorized. Compare the fresh candidate balance, recipient payout, and fee components exactly with the confirmation, or pass an SDK-enforced confirmed payout cap.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: security-auditor)
Still open from earlier rounds (1)
- 🔴 Blocking: Detect wallet or network changes that occur during asynchronous send preparation —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:332-377(thread)
Disputed — left to maintainers (1)
- 🔴 Blocking: Make a built BIP70 send one-shot across postAndBroadcast —
DashWallet/Sources/Models/PaymentProtocol/BIP70PaymentService.swift:323-359(thread)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff is large and intricate and directly changes funds-movement paths, including transaction preparation, signing, broadcasting, asset-lock recovery, and Core-to-Platform sends in ExternalSendExecutor and CoreFundingResumer. - 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— 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/InternalTransfer/Shielded/ShieldedTransferCoordinator.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/InternalTransfer/Shielded/ShieldedTransferCoordinator.swift:1260-1263: Require the confirmed Max payout to remain unchanged before draining to an external shielded address
The external Max drain still accepts a changed, smaller payout. `drainConfirmation` permits the fresh recipient quote when `recipientCredits / 1000 <= confirmedDuffs`, and `drainStillMatches` permits a lower candidate balance with the same `<=` comparison. The SDK drain then recomputes the eligible notes and payout without receiving the confirmed amount as an execution cap, so a balance or fee change while Confirm is open can send a different amount than the user authorized. Compare the fresh candidate balance, recipient payout, and fee components exactly with the confirmation, or pass an SDK-enforced confirmed payout cap.
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [BLOCKING] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:332-377: Detect wallet or network changes that occur during asynchronous send preparation
(carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1407#discussion_r4569271418)
4459025 to
1786602
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (queue backlog)
Changes requested: 3 blockers
- Updating the app removes Retry for unfinished Core-to-Platform top-ups —
DashWallet/Sources/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift:384-387(new)
Impact: A holder who updates after the Core lock commits but before their own Platform balance is credited loses in-app recovery even when all wallet data survives. - Core-to-Platform funding can broadcast after its recovery record fails to save —
DashWallet/Sources/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift:177-189(new)
Impact: A holder starting a Core-to-Platform transfer can be left with locked DASH and no in-app retry if the recipient file cannot be updated and the Platform step does not finish. - Delete All Wallets can report success while payment records remain on disk —
DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKWalletWiper.swift:950(new)
Impact: A holder who chooses Delete All Wallets can receive a successful result after a recipient-file replacement failure leaves old outpoints, recipient hashes, and amounts on the device.
Not counted: 2 disputed blocking finding(s) left to maintainers.
New on this head: This revision moves Core-to-Platform recovery records from preferences into an atomically replaced file, removes the age-based ownership fallback, and checks typed Platform withdrawals against the address they actually spend from. The exact-head CI reports passing title and CodeRabbit checks and a pending review check, but no build or XCTest result; funded route testing remains unconfirmed.
A pattern across this PR's review rounds
This is review round 13, and the PR has drawn 29 blocking findings so far. 4 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.
1. Asset locks still lack durable recipient intent (3 new in this round, 1 earlier finding(s))
The pinned SDK records own top-ups and third-party Core-to-Platform payments as the same lock type without recording who should be paid, and its AssetLockBuiltHandler cannot stop broadcast if FileFundingRecipientStore fails to save. Removing the date cutoff stops CoreFundingRecipientCheck from guessing that an unmarked lock is owned, but it also removes Retry for intact pre-upgrade top-ups that never had a mark to migrate. The separate file has its own cleanup path, where the same log-and-return write failure lets SwiftDashSDKWalletWiper report success without erasing the records.
Already tracked: dashpay/platform#5824
In this round: Updating the app removes Retry for unfinished Core-to-Platform top-ups; Core-to-Platform funding can broadcast after its recovery record fails to save; Delete All Wallets can report success while payment records remain on disk
Suggested decision (land the prerequisite first): Land SDK-owned recipient intent separately: commit who should be paid and whether the recipient belongs to the wallet with the asset lock before broadcast, and have recovery honor that record or refuse without guessing. If #1407 needs to land first, leave out third-party Core-to-Platform funding and the shared recovery changes it requires so existing own top-ups keep their Retry path.
🔴 3 blocking
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — ExternalSendExecutor.swift orchestrates preparation and broadcast across multiple spend routes, while CoreFundingResumer.swift changes how interrupted transfers are recovered and which recipient can receive the locked funds. - Phase 1 reviewers: not run (skipped for throughput: 15 PRs queued, above the 10 limit)
- New since the last final review (
44590251): 3 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 3 confirmed - 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— 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): Asset locks still lack durable recipient intent. When you fix the findings below, fix the cause, not only the reported case. The review suggests (land the prerequisite first): Land SDK-owned recipient intent separately: commit who should be paid and whether the recipient belongs to the wallet with the asset lock before broadcast, and have recovery honor that record or refuse without guessing. If #1407 needs to land first, leave out third-party Core-to-Platform funding and the shared recovery changes it requires so existing own top-ups keep their Retry path. 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/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift`:
- [BLOCKING] DashWallet/Sources/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift:384-387: Updating the app removes Retry for unfinished Core-to-Platform top-ups
Impact: A holder who updates after the Core lock commits but before their own Platform balance is credited loses in-app recovery even when all wallet data survives.
An in-place update can leave a previously recoverable top-up locked. On the base revision, the existing Internal Transfer flow funds the wallet's own Platform addresses without writing an own mark, and transaction details can retry the pending type-4 lock through `resumeFundFromCore`. The pinned SDK's row upsert does not populate `recipientIsExternal`, and the new file migration imports only preference entries the base never wrote. Once this revision removes the cutoff, that original, intact row fails `CoreFundingRecipientCheck`: `TxDetailModel` hides Retry, and `resumeFundPlatform` refuses the same lock before authorization if reached directly. Keep the cutoff removed, but add an upgrade path based on verified per-outpoint evidence or a separately authorized recovery flow that asks the holder to confirm the destination. Test an intact in-place upgrade separately from a chain restore with an unknown recipient.
_Confirmed by an independent pass: A user whose Internal Transfer locked DASH on Core but did not finish on Platform can update the app in place with the original type-4 lock row intact. When they reopen transaction details, the update hides the previously available Complete Transfer action, and a direct resume is refused before the PIN prompt. The DASH remains locked with no supported way to finish the transfer._
- [BLOCKING] DashWallet/Sources/Infrastructure/SwiftDashSDK/CoreFundingResumer.swift:177-189: Core-to-Platform funding can broadcast after its recovery record fails to save
Impact: A holder starting a Core-to-Platform transfer can be left with locked DASH and no in-app retry if the recipient file cannot be updated and the Platform step does not finish.
An unsuccessful recovery-record write does not stop the lock from going on-chain. The existing Internal Transfer screen reaches `performFundPlatform` → `fundFromCore` → `CoreFunder.fundOwn`, whose built handler calls `markOwn`; external funding calls `save` at the same point. If the file is unreadable or the atomic write fails, for example because storage is full, `update` logs and returns normally. At the pinned `dashpay/platform` revision, `AssetLockBuiltHandler` returns `Void`: after it returns, native code queues the row and proceeds to broadcast without checking the app's write, and the row does not carry the Platform recipient discriminator. If the Platform step is then interrupted, making the store readable or writable again does not recreate the missing record, so recovery still refuses the lock. Make durable recipient recording a prerequisite for broadcast at the SDK funding boundary, or disable funding paths that cannot guarantee it. A writability preflight alone cannot catch a failed final write; cover that failure in a regression test that verifies no broadcast.
_Confirmed by an independent pass: A user confirms a Core-to-Platform top-up in Internal Transfer while the device is too full to atomically write the recovery file. The write failure does not stop Core broadcast; if the app closes before Platform consumes the lock, freeing storage afterward does not recreate the missing own mark. The wallet refuses recovery and leaves the DASH locked._
In `DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKWalletWiper.swift`:
- [BLOCKING] DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKWalletWiper.swift:950: Delete All Wallets can report success while payment records remain on disk
Impact: A holder who chooses Delete All Wallets can receive a successful result after a recipient-file replacement failure leaves old outpoints, recipient hashes, and amounts on the device.
A full wipe can succeed in the UI without erasing the new recipient file. After SDK wallet deletion, `performWipe` commits the PIN and app-state reset, then calls `resetForWipe()` through the nonthrowing preferences cleanup. That method replaces the file with an empty store, but `FileFundingRecipientStore.update` only logs a failed atomic write, leaving the original file intact. No later wipe step removes it, and the Delete All UI only alerts on a failed wipe result. This violates the project's fail-closed wipe rule. Make cleanup idempotent and fallible, treat an already absent file as success, and perform it alongside `CoreShieldedDrainFileStore.clear()` before the app-state commit point. Test that a cleanup error is reported and that a retry completes the erase.
_Confirmed by an independent pass: A user with a saved top-up marker confirms Delete All Wallets, SDK deletion succeeds, and the atomic replacement of FundingRecipients.json fails, for example because there is no space for the temporary file. The wipe still returns success and the UI offers no retry, even though the old wallet's transfer metadata remains on disk._
| guard rowMark == false || recipientStore.isMarkedOwn(outPointHex: outPointHex) else { | ||
| log("Asset lock has neither a recipient record nor an own mark; not resumed") | ||
| throw CoreFundingResumer.ResumeError.recipientUnknown | ||
| } |
There was a problem hiding this comment.
✅ Resolved at
3467aa30; see the replies below.
🔴 Blocking: Updating the app removes Retry for unfinished Core-to-Platform top-ups
Impact: A holder who updates after the Core lock commits but before their own Platform balance is credited loses in-app recovery even when all wallet data survives.
An in-place update can leave a previously recoverable top-up locked. On the base revision, the existing Internal Transfer flow funds the wallet's own Platform addresses without writing an own mark, and transaction details can retry the pending type-4 lock through resumeFundFromCore. The pinned SDK's row upsert does not populate recipientIsExternal, and the new file migration imports only preference entries the base never wrote. Once this revision removes the cutoff, that original, intact row fails CoreFundingRecipientCheck: TxDetailModel hides Retry, and resumeFundPlatform refuses the same lock before authorization if reached directly. Keep the cutoff removed, but add an upgrade path based on verified per-outpoint evidence or a separately authorized recovery flow that asks the holder to confirm the destination. Test an intact in-place upgrade separately from a chain restore with an unknown recipient.
Confirmed by an independent pass: A user whose Internal Transfer locked DASH on Core but did not finish on Platform can update the app in place with the original type-4 lock row intact. When they reopen transaction details, the update hides the previously available Complete Transfer action, and a direct resume is refused before the PIN prompt. The DASH remains locked with no supported way to finish the transfer.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Resolved in 3467aa3 by scope: third-party Core → Platform address funding leaves this PR until dashpay/platform#5824 lets the SDK own the recipient intent. SendRoute.coreToPlatform is gone (Core → someone else's Platform address is shown as unavailable), CoreFundingResumer and its tests are deleted, and PlatformAddressSyncCoordinator fund/resume, TxDetailModel Retry, ShieldedTransferCoordinator and SwiftDashSDKWalletWiper are back to develop, so own top-ups keep develop's Retry and no recipient file is written or wiped. Kept: the own-top-up wallet/network recheck after the PIN and the early beginFundingCall. Internal test builds that ran an earlier revision may keep an unread FundingRecipients.json; noted in the test notes.
There was a problem hiding this comment.
Resolved (re-reviewed at 3467aa30): Transaction details use the base Retry predicate again, and resumeFundPlatform reaches the own-wallet funding seam without requiring a recipient marker. An intact pending top-up from the base needs no new metadata after an update.
| case .unreadable: | ||
| DWLogger.log("Funding recipient store is unreadable; not changed") | ||
| return | ||
| } | ||
| change(&contents) | ||
| do { | ||
| try FileManager.default.createDirectory( | ||
| at: fileURL.deletingLastPathComponent(), withIntermediateDirectories: true) | ||
| try JSONEncoder().encode(contents).write(to: fileURL, options: .atomic) | ||
| removeLegacyEntries() | ||
| } catch { | ||
| DWLogger.log("Funding recipient store write failed: \(type(of: error))") | ||
| } |
There was a problem hiding this comment.
✅ Resolved at
3467aa30; see the replies below.
🔴 Blocking: Core-to-Platform funding can broadcast after its recovery record fails to save
Impact: A holder starting a Core-to-Platform transfer can be left with locked DASH and no in-app retry if the recipient file cannot be updated and the Platform step does not finish.
An unsuccessful recovery-record write does not stop the lock from going on-chain. The existing Internal Transfer screen reaches performFundPlatform → fundFromCore → CoreFunder.fundOwn, whose built handler calls markOwn; external funding calls save at the same point. If the file is unreadable or the atomic write fails, for example because storage is full, update logs and returns normally. At the pinned dashpay/platform revision, AssetLockBuiltHandler returns Void: after it returns, native code queues the row and proceeds to broadcast without checking the app's write, and the row does not carry the Platform recipient discriminator. If the Platform step is then interrupted, making the store readable or writable again does not recreate the missing record, so recovery still refuses the lock. Make durable recipient recording a prerequisite for broadcast at the SDK funding boundary, or disable funding paths that cannot guarantee it. A writability preflight alone cannot catch a failed final write; cover that failure in a regression test that verifies no broadcast.
Confirmed by an independent pass: A user confirms a Core-to-Platform top-up in Internal Transfer while the device is too full to atomically write the recovery file. The write failure does not stop Core broadcast; if the app closes before Platform consumes the lock, freeing storage afterward does not recreate the missing own mark. The wallet refuses recovery and leaves the DASH locked.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Resolved in 3467aa3 by scope: third-party Core → Platform address funding leaves this PR until dashpay/platform#5824 lets the SDK own the recipient intent. SendRoute.coreToPlatform is gone (Core → someone else's Platform address is shown as unavailable), CoreFundingResumer and its tests are deleted, and PlatformAddressSyncCoordinator fund/resume, TxDetailModel Retry, ShieldedTransferCoordinator and SwiftDashSDKWalletWiper are back to develop, so own top-ups keep develop's Retry and no recipient file is written or wiped. Kept: the own-top-up wallet/network recheck after the PIN and the early beginFundingCall. Internal test builds that ran an earlier revision may keep an unread FundingRecipients.json; noted in the test notes.
There was a problem hiding this comment.
Resolved (re-reviewed at 3467aa30): The external funding entry point and its file-writing handler are gone. The retained own-wallet top-up no longer depends on a separate recipient record to recover a broadcast lock.
| ShieldedWithdrawalStore.shared.resetForWipe() | ||
| AssetLockProbeStore.shared.resetForWipe() | ||
| AssetLockFailureStore.shared.resetForWipe() | ||
| FileFundingRecipientStore.standard.resetForWipe() |
There was a problem hiding this comment.
✅ Resolved at
3467aa30; see the replies below.
🔴 Blocking: Delete All Wallets can report success while payment records remain on disk
Impact: A holder who chooses Delete All Wallets can receive a successful result after a recipient-file replacement failure leaves old outpoints, recipient hashes, and amounts on the device.
A full wipe can succeed in the UI without erasing the new recipient file. After SDK wallet deletion, performWipe commits the PIN and app-state reset, then calls resetForWipe() through the nonthrowing preferences cleanup. That method replaces the file with an empty store, but FileFundingRecipientStore.update only logs a failed atomic write, leaving the original file intact. No later wipe step removes it, and the Delete All UI only alerts on a failed wipe result. This violates the project's fail-closed wipe rule. Make cleanup idempotent and fallible, treat an already absent file as success, and perform it alongside CoreShieldedDrainFileStore.clear() before the app-state commit point. Test that a cleanup error is reported and that a retry completes the erase.
Confirmed by an independent pass: A user with a saved top-up marker confirms Delete All Wallets, SDK deletion succeeds, and the atomic replacement of FundingRecipients.json fails, for example because there is no space for the temporary file. The wipe still returns success and the UI offers no retry, even though the old wallet's transfer metadata remains on disk.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Resolved in 3467aa3 by scope: third-party Core → Platform address funding leaves this PR until dashpay/platform#5824 lets the SDK own the recipient intent. SendRoute.coreToPlatform is gone (Core → someone else's Platform address is shown as unavailable), CoreFundingResumer and its tests are deleted, and PlatformAddressSyncCoordinator fund/resume, TxDetailModel Retry, ShieldedTransferCoordinator and SwiftDashSDKWalletWiper are back to develop, so own top-ups keep develop's Retry and no recipient file is written or wiped. Kept: the own-top-up wallet/network recheck after the PIN and the early beginFundingCall. Internal test builds that ran an earlier revision may keep an unread FundingRecipients.json; noted in the test notes.
There was a problem hiding this comment.
Resolved (re-reviewed at 3467aa30): I verified that this revision neither creates FundingRecipients.json nor adds its best-effort replacement to Delete All Wallets. As you note, that removes the failure on the supported upgrade path without cleaning up files left by earlier internal builds.
| private func predatesOwnMarks(_ row: PersistentAssetLock?) -> Bool { | ||
| guard let row, let start = recipientStore.ownMarkingStart, | ||
| row.statusRaw != AssetLockRecoveryService.recoveredFromChainStatus else { return false } | ||
| return row.createdAt < start |
There was a problem hiding this comment.
Resolved (re-reviewed at 1786602e): The current check no longer uses age or status as ownership evidence. I verified that an unmarked row is refused and a file read error cannot fall through to the wallet's own addresses.
1786602 to
3467aa3
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (queue backlog)
Nothing blocks: no blocking finding stands on this head.
Not counted: 2 disputed blocking finding(s) left to maintainers.
New on this head: This revision removes third-party Core-to-Platform address funding and its recipient store, preserves Retry for own-wallet top-ups, and adds checks when dispatching Identity Max sends and opening DashSpend payment links. On the exact head, the PR-title checks passed and the review check was in progress; no iOS build, XCTest result, or funded-route smoke was reported for this revision.
🟡 2 suggestion(s)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — ExternalSendExecutor.swift adds intricate multi-route funds-movement logic that controls when transactions are signed and broadcast, while ShieldedTransferCoordinator.swift changes how recipients are verified during asset-lock recovery. - Phase 1 reviewers: not run (skipped for throughput: 13 PRs queued, above the 10 limit)
- 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— security-auditor (completed, effort high); 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/ExternalSendExecutor.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:593-596: Identity Max can leave less than the DashPay reserve when the local balance is stale
Impact: Once the new Send screen uses this executor, a holder who spends identity credits on another device can confirm Max and be left below the DashPay reserve.
Confirm can approve a Max payment that leaves the identity below the reserve. The new dispatch check calls the same balance reader as preparation: `LiveExternalSendBalances` uses `refreshedSnapshot()`, which rebuilds the app snapshot from the SDK's locally stored identity balance or the persisted fallback without querying Platform. If the actual balance still covers the payment and fee but no longer covers the reserve, Platform can accept the spend because the reserve is an app rule. For this Max-only check, use the result of `wallet.refreshIdentityBalance(identityId:)` for the prepared identity through the balance seam, reject refresh failures without falling back to the cache, and keep the context check after the await. Test a stale high cache with a lower network balance and with a failed refresh.
In `DashWallet/Sources/Models/Transactions/SendCoinsService.swift`:
- [SUGGESTION] DashWallet/Sources/Models/Transactions/SendCoinsService.swift:89-91: DashSpend rejects payment links whose callback schemes differ only in case
Impact: A gift-card buyer whose payment link names the same callback as `sender=ShopApp` and `req-sender=shopapp` sees “Invalid payment request” before the app fetches the request.
DashSpend rejects a link even when it names only one callback app. The new guard in `payWithDashUrl` rejects `hasConflictingCallback`, but `BIP70URI` sets that flag using case-sensitive string inequality. URL schemes are case-insensitive, and `CallbackScheme.validated` accepts both spellings. Compare valid schemes case-insensitively in `BIP70URI` so all callers agree, preserve rejection for genuinely different schemes, and add a mixed-case case alongside the conflicting-callback test.
Not approved: 2 blocking finding(s) are disputed and left to the maintainers.
| private func identityMaxRefusal(_ prepared: PreparedExternalSend) async -> SendOutcome? { | ||
| guard prepared.route.source == .identity, prepared.isMax else { return nil } | ||
| guard let balance = await balances.spendableBalance(of: .identity), | ||
| AmountRules.check(amount: prepared.amount, source: .identity, balance: balance, fee: prepared.fee) == .ok |
There was a problem hiding this comment.
✅ Resolved at
3b676f07; see the replies below.
🟡 Suggestion: Identity Max can leave less than the DashPay reserve when the local balance is stale
Impact: Once the new Send screen uses this executor, a holder who spends identity credits on another device can confirm Max and be left below the DashPay reserve.
Confirm can approve a Max payment that leaves the identity below the reserve. The new dispatch check calls the same balance reader as preparation: LiveExternalSendBalances uses refreshedSnapshot(), which rebuilds the app snapshot from the SDK's locally stored identity balance or the persisted fallback without querying Platform. If the actual balance still covers the payment and fee but no longer covers the reserve, Platform can accept the spend because the reserve is an app rule. For this Max-only check, use the result of wallet.refreshIdentityBalance(identityId:) for the prepared identity through the balance seam, reject refresh failures without falling back to the cache, and keep the context check after the await. Test a stale high cache with a lower network balance and with a failed refresh.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in 3b676f0: the Identity Max reserve check at dispatch reads the prepared identity's balance from Platform (IdentityNetworkBalanceReading, through refreshIdentityBalance), not the stored one. A failed read refuses the Max; the wallet and network check after the await stays.
There was a problem hiding this comment.
Resolved (re-reviewed at 3b676f07): Your new seam queries the prepared identity through refreshIdentityBalance, refuses a missing answer without using the app cache, and rechecks wallet and identity context after the await. The regression test leaves the stored balance high while lowering or removing the network answer.
| // A link naming two different apps to call back leaves which one open: it is refused like any invalid link. | ||
| guard let uri = BIP70URI(paymentUrlString), let requestURL = uri.r, !uri.hasConflictingCallback else { | ||
| throw DashSpendError.paymentProcessingError(NSLocalizedString("Invalid payment request", comment: "DashSpend")) |
There was a problem hiding this comment.
✅ Resolved at
3b676f07; see the replies below.
🟡 Suggestion: DashSpend rejects payment links whose callback schemes differ only in case
Impact: A gift-card buyer whose payment link names the same callback as sender=ShopApp and req-sender=shopapp sees “Invalid payment request” before the app fetches the request.
DashSpend rejects a link even when it names only one callback app. The new guard in payWithDashUrl rejects hasConflictingCallback, but BIP70URI sets that flag using case-sensitive string inequality. URL schemes are case-insensitive, and CallbackScheme.validated accepts both spellings. Compare valid schemes case-insensitively in BIP70URI so all callers agree, preserve rejection for genuinely different schemes, and add a mixed-case case alongside the conflicting-callback test.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Resolved (re-reviewed at 3b676f07): Your fix in #1406 is present on this base: BIP70URI compares callback schemes without regard to case, and the DashSpend guard uses that result. The current tests cover both a mixed-case match and a genuine conflict.
| guard rowMark == false || recipientStore.isMarkedOwn(outPointHex: outPointHex) else { | ||
| log("Asset lock has neither a recipient record nor an own mark; not resumed") | ||
| throw CoreFundingResumer.ResumeError.recipientUnknown | ||
| } |
There was a problem hiding this comment.
Resolved (re-reviewed at 3467aa30): Transaction details use the base Retry predicate again, and resumeFundPlatform reaches the own-wallet funding seam without requiring a recipient marker. An intact pending top-up from the base needs no new metadata after an update.
| case .unreadable: | ||
| DWLogger.log("Funding recipient store is unreadable; not changed") | ||
| return | ||
| } | ||
| change(&contents) | ||
| do { | ||
| try FileManager.default.createDirectory( | ||
| at: fileURL.deletingLastPathComponent(), withIntermediateDirectories: true) | ||
| try JSONEncoder().encode(contents).write(to: fileURL, options: .atomic) | ||
| removeLegacyEntries() | ||
| } catch { | ||
| DWLogger.log("Funding recipient store write failed: \(type(of: error))") | ||
| } |
There was a problem hiding this comment.
Resolved (re-reviewed at 3467aa30): The external funding entry point and its file-writing handler are gone. The retained own-wallet top-up no longer depends on a separate recipient record to recover a broadcast lock.
| ShieldedWithdrawalStore.shared.resetForWipe() | ||
| AssetLockProbeStore.shared.resetForWipe() | ||
| AssetLockFailureStore.shared.resetForWipe() | ||
| FileFundingRecipientStore.standard.resetForWipe() |
There was a problem hiding this comment.
Resolved (re-reviewed at 3467aa30): I verified that this revision neither creates FundingRecipients.json nor adds its best-effort replacement to Delete All Wallets. As you note, that removes the failure on the supported upgrade path without cleaning up files left by earlier internal builds.
3467aa3 to
a347401
Compare
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Nothing blocks: no blocking finding stands on this head.
Not counted: 2 disputed blocking finding(s) left to maintainers.
New on this head: The rebase updates the base branch without changing the external-send services patch or its BIP70 handling. At the reviewed head, test-target membership, workflow lint, recovery, and accessibility checks passed; the simulator suite is still pending. Funded end-to-end sends were not verified.
🟡 2 suggestion(s)
Still open from earlier rounds (2)
- 🟡 Suggestion: DashSpend rejects payment links whose callback schemes differ only in case —
DashWallet/Sources/Models/Transactions/SendCoinsService.swift:89-91(thread) - 🟡 Suggestion: Identity Max can leave less than the DashPay reserve when the local balance is stale —
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:593-596(thread)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — ExternalSendExecutor.swift adds intricate routing from authenticated preparation to confirmed broadcast, and ShieldedTransferCoordinator.swift changes which recipient can receive funds from a recovered asset lock. - 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(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); 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/Models/Transactions/SendCoinsService.swift`:
- [SUGGESTION] DashWallet/Sources/Models/Transactions/SendCoinsService.swift:89-91: DashSpend rejects payment links whose callback schemes differ only in case
(carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1407#discussion_r4678438509)
In `DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:593-596: Identity Max can leave less than the DashPay reserve when the local balance is stale
(carried; thread: https://github.com/dashpay/dashwallet-ios/pull/1407#discussion_r4678438488)
Not approved: 2 blocking finding(s) are disputed and left to the maintainers.
a347401 to
3b676f0
Compare
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Changes requested: 2 blockers
- History counts the shielded pool fee as money sent to the recipient —
DashWallet/Sources/Models/Transactions/Model/Transaction.swift:228-230(new; not shown inline, see below)
Impact: A holder who sends a typed amount from Core to someone else's Shielded address sees an “Amount Sent” larger than what the recipient received. - History says “Sent” before Platform finishes a shielded payment —
DashWallet/Sources/Models/Transactions/Model/Transaction.swift:393-395(new; not shown inline, see below)
Impact: A holder returning to History after a Core-to-Shielded payment stalls can see “Sent” even though the recipient has not been credited.
Not counted: 2 disputed blocking finding(s) left to maintainers.
New on this head: This revision refreshes Identity Max balances from Platform before dispatch, changes how Core-to-Identity top-ups fund the Platform fee, tightens BIP70 link parsing, and adds recipient-aware History for Core-to-Shielded payments. At the reviewed head, simulator tests, test target membership, workflow lint, and accessibility passed; recovery was still pending, and no funded end-to-end send was verified.
A pattern across this PR's review rounds
This is review round 16, and the PR has drawn 31 blocking findings so far. 2 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.
1. History treats the funding lock as the payment (4 new in this round finding(s))
After the third-party Core-to-Platform route was removed, this services PR added a separate History change that turns the Core funding transaction into an outgoing Shielded payment without distinguishing the two steps. Transaction uses the gross lock value as the recipient payout and Core confirmation as payment completion, even though Platform credits the recipient separately. ShieldedTxLookup also resolves ownership through a blocking SDK call on History refresh and renders an unknown answer the same way as a confirmed transfer to self.
In this round: History counts the shielded pool fee as money sent to the recipient; History says “Sent” before Platform finishes a shielded payment; History calls a shielded payment a transfer to self when ownership is unknown; Shielded History blocks the UI thread once per uncached recipient
Suggested decision (split the PR): Keep #1407 focused on send services and payment-request handling, with third-party Core-to-Platform funding still unavailable and the existing own-wallet Retry path intact. Move the Core-to-Shielded History and transaction-details changes into a separate PR that distinguishes funds locked on Core from what Platform has actually paid.
🔴 2 blocking | 🟡 3 suggestion(s)
5 finding(s) not shown inline (GitHub refused the PR diff as too large)
🔴 Blocking: History counts the shielded pool fee as money sent to the recipient
Impact: A holder who sends a typed amount from Core to someone else's Shielded address sees an “Amount Sent” larger than what the recipient received.
DashWallet/Sources/Models/Transactions/Model/Transaction.swift:228-230
The details screen attributes part of the fee to the recipient. The existing SendScreen.confirm() passes the typed payout to performAssetLock, which adds the pool fee to the lock; the pinned SDK subtracts that fee before crediting the recipient. The new .sent projection makes details label the amount “Amount Sent,” but dashAmount and the signed History amount still use PersistentAssetLock.amountDuffs, the gross lock value. Keep that gross value for recovery, but show the recorded net payout in payment history. If the payout is unavailable, label the gross value as “Amount locked” rather than attributing it to the recipient. The current fixture has only one amount; add a case where a nonzero pool fee makes the lock and payout different.
Confirmed by an independent pass: A user confirms a fixed-amount send from Transparent to someone else's Shielded address in the existing Send screen, then opens the completed payment from History. The Core lock includes the pool fee, which the pinned SDK deducts before crediting the recipient, but History shows the gross lock value as an outgoing payment and Details labels that same value “Amount Sent” to the recipient.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
🔴 Blocking: History says “Sent” before Platform finishes a shielded payment
Impact: A holder returning to History after a Core-to-Shielded payment stalls can see “Sent” even though the recipient has not been credited.
DashWallet/Sources/Models/Transactions/Model/Transaction.swift:393-395
History can report completion for an unpaid recipient. The existing Send screen creates a Core funding lock before the Platform shield transition; if that transition stalls or fails after the Core lock confirms, the persisted lock can remain at status 2 or 3 and appear in History on refresh or reopen. The new external-recipient projection removes the internal route, so stateTitle falls through to the classic outgoing title. That title uses the Core transaction state, which is already .ok at InstantSend, without checking whether Platform consumed the lock. The retry pill is a separate detail, so a stuck row can say both “Sent” and “Pending — tap to finish”; while the lock is claimed, Home suppresses that pill. Keep the outgoing direction, but derive the payment title from the asset-lock status, reserving “Sent” for verified completion. Test a Core-confirmed transaction with a non-consumed lock; the current fixture only covers a consumed lock.
Confirmed by an independent pass: A user confirms a Transparent-to-Shielded send to someone else's address, Core confirms the funding lock, and the subsequent Platform submission fails before crediting the recipient. On reopening the app, History can load the persisted InstantSend- or ChainLocked lock and title the row “Sent” even though the recipient has not been paid.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
🟡 Suggestion: DashSpend can pay an invoice even when the link's required amount is invalid
Impact: A gift-card buyer can authorize and pay the fetched invoice even though the provider's link specifies a required amount the app cannot interpret.
DashWallet/Sources/Models/Transactions/SendCoinsService.swift:92-94
The headless flow can pay a link that interactive Send refuses. This revision extends payWithDashUrl to reject ambiguous request URLs and required text, but its guard omits the combination that BIP70URI already exposes: hasInvalidAmount and a required amount. That covers malformed values and conflicting repeated amounts. After the guard, confirmAndSendHeadless authorizes, fetches, and builds from the invoice outputs without receiving the URI's amount requirement. Share the required-amount check with the interactive parsers while keeping their callback policies separate. Test that an invoice can supply the amount when the URI's optional amount is malformed, but cannot override a malformed or contradictory required amount.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
🟡 Suggestion: History calls a shielded payment a transfer to self when ownership is unknown
Impact: A holder viewing a recorded shielded payment while the ownership check is unavailable can see “Internal Transfer” and “To: Shielded balance” for someone else's address.
DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:2449-2453
An unavailable ownership check hides the recorded recipient and asserts a transfer to self. The pinned SDK returns nil for an unbound shielded account, and the live adapter also returns nil when it cannot query the manager. The new resolver leaves the same projection for nil as for a confirmed own address; the route, details destination, and default tax category then all read as internal. Keep own, external, and unknown distinct. When ownership is unknown, show the recorded address without calling it either an own balance or a confirmed external payment. Change the undecided-owner test to cover that neutral presentation and a later successful resolution.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
🟡 Suggestion: Shielded History blocks the UI thread once per uncached recipient
Impact: A holder opening a wallet with many distinct shielded recipients can experience a UI stall during the first History refresh.
DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:2348-2354
The first recipient-resolution pass can stall the UI even though the database read is off-main. After that read, refresh walks the full retained lock snapshot on MainActor. Each cache miss calls the pinned SDK's synchronous isOwnShieldedAddress; the Rust FFI uses runtime().block_on to acquire the wallet and its viewing keys before checking the address. Caching does not help the first pass, and undecided answers are retried on later refreshes. Put the ownership read behind a worker-backed or batched SwiftDashSDK API, then recheck the refresh generation and container before publishing the resolved snapshot.
source: gpt-6.2-astra (phase2-reviewer: general, 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: Small Core-to-Identity top-ups fail even when the funded lock clears the SDK minimum
Impact: Once the new Send screen uses this executor, a holder can authenticate and confirm a small top-up only to get an incorrect below-minimum refusal.
DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:708-712
The executor can refuse an affordable top-up after Confirm for a minimum its lock already meets. This revision changes toIdentity to submit the payout plus the 50,500-duff Platform allowance, but the dispatch guard still applies the SDK's minimum to the payout alone. A 50,499-duff payout now implies a 100,999-duff lock, and the pinned FFI checks the lock, not the payout, against its 50,500-duff floor. Apply that floor to the checked lock sum and update the test that expects a refusal at 50,499 duffs. If the product requires a separate minimum payout, name and validate that rule before authentication.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — ExternalSendExecutor.swift changes how multiple funds-movement routes are authorized, prepared, and committed, while CoreFundingResumer changes when an interrupted transfer can resume and which recipient it can pay. - 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(lane failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- New since the last final review (
a3474013): 2 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 2 confirmed; 1 suggestion(s) on unchanged code listed as follow-up candidates - 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— 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): History treats the funding lock as the payment. When you fix the findings below, fix the cause, not only the reported case. The review suggests (split the PR): Keep #1407 focused on send services and payment-request handling, with third-party Core-to-Platform funding still unavailable and the existing own-wallet Retry path intact. Move the Core-to-Shielded History and transaction-details changes into a separate PR that distinguishes funds locked on Core from what Platform has actually paid. 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/Models/Transactions/Model/Transaction.swift`:
- [BLOCKING] DashWallet/Sources/Models/Transactions/Model/Transaction.swift:228-230: History counts the shielded pool fee as money sent to the recipient
Impact: A holder who sends a typed amount from Core to someone else's Shielded address sees an “Amount Sent” larger than what the recipient received.
The details screen attributes part of the fee to the recipient. The existing `SendScreen.confirm()` passes the typed payout to `performAssetLock`, which adds the pool fee to the lock; the pinned SDK subtracts that fee before crediting the recipient. The new `.sent` projection makes details label the amount “Amount Sent,” but `dashAmount` and the signed History amount still use `PersistentAssetLock.amountDuffs`, the gross lock value. Keep that gross value for recovery, but show the recorded net payout in payment history. If the payout is unavailable, label the gross value as “Amount locked” rather than attributing it to the recipient. The current fixture has only one amount; add a case where a nonzero pool fee makes the lock and payout different.
_Confirmed by an independent pass: A user confirms a fixed-amount send from Transparent to someone else's Shielded address in the existing Send screen, then opens the completed payment from History. The Core lock includes the pool fee, which the pinned SDK deducts before crediting the recipient, but History shows the gross lock value as an outgoing payment and Details labels that same value “Amount Sent” to the recipient._
- [BLOCKING] DashWallet/Sources/Models/Transactions/Model/Transaction.swift:393-395: History says “Sent” before Platform finishes a shielded payment
Impact: A holder returning to History after a Core-to-Shielded payment stalls can see “Sent” even though the recipient has not been credited.
History can report completion for an unpaid recipient. The existing Send screen creates a Core funding lock before the Platform shield transition; if that transition stalls or fails after the Core lock confirms, the persisted lock can remain at status 2 or 3 and appear in History on refresh or reopen. The new external-recipient projection removes the internal route, so `stateTitle` falls through to the classic outgoing title. That title uses the Core transaction state, which is already `.ok` at InstantSend, without checking whether Platform consumed the lock. The retry pill is a separate detail, so a stuck row can say both “Sent” and “Pending — tap to finish”; while the lock is claimed, Home suppresses that pill. Keep the outgoing direction, but derive the payment title from the asset-lock status, reserving “Sent” for verified completion. Test a Core-confirmed transaction with a non-consumed lock; the current fixture only covers a consumed lock.
_Confirmed by an independent pass: A user confirms a Transparent-to-Shielded send to someone else's address, Core confirms the funding lock, and the subsequent Platform submission fails before crediting the recipient. On reopening the app, History can load the persisted InstantSend- or ChainLocked lock and title the row “Sent” even though the recipient has not been paid._
In `DashWallet/Sources/Models/Transactions/SendCoinsService.swift`:
- [SUGGESTION] DashWallet/Sources/Models/Transactions/SendCoinsService.swift:92-94: DashSpend can pay an invoice even when the link's required amount is invalid
Impact: A gift-card buyer can authorize and pay the fetched invoice even though the provider's link specifies a required amount the app cannot interpret.
The headless flow can pay a link that interactive Send refuses. This revision extends `payWithDashUrl` to reject ambiguous request URLs and required text, but its guard omits the combination that `BIP70URI` already exposes: `hasInvalidAmount` and a required `amount`. That covers malformed values and conflicting repeated amounts. After the guard, `confirmAndSendHeadless` authorizes, fetches, and builds from the invoice outputs without receiving the URI's amount requirement. Share the required-amount check with the interactive parsers while keeping their callback policies separate. Test that an invoice can supply the amount when the URI's optional amount is malformed, but cannot override a malformed or contradictory required amount.
In `DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift`:
- [SUGGESTION] DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:2449-2453: History calls a shielded payment a transfer to self when ownership is unknown
Impact: A holder viewing a recorded shielded payment while the ownership check is unavailable can see “Internal Transfer” and “To: Shielded balance” for someone else's address.
An unavailable ownership check hides the recorded recipient and asserts a transfer to self. The pinned SDK returns `nil` for an unbound shielded account, and the live adapter also returns `nil` when it cannot query the manager. The new resolver leaves the same projection for `nil` as for a confirmed own address; the route, details destination, and default tax category then all read as internal. Keep own, external, and unknown distinct. When ownership is unknown, show the recorded address without calling it either an own balance or a confirmed external payment. Change the undecided-owner test to cover that neutral presentation and a later successful resolution.
- [SUGGESTION] DashWallet/Sources/Infrastructure/SwiftDashSDK/PlatformAddressSyncCoordinator.swift:2348-2354: Shielded History blocks the UI thread once per uncached recipient
Impact: A holder opening a wallet with many distinct shielded recipients can experience a UI stall during the first History refresh.
The first recipient-resolution pass can stall the UI even though the database read is off-main. After that read, `refresh` walks the full retained lock snapshot on `MainActor`. Each cache miss calls the pinned SDK's synchronous `isOwnShieldedAddress`; the Rust FFI uses `runtime().block_on` to acquire the wallet and its viewing keys before checking the address. Caching does not help the first pass, and undecided answers are retried on later refreshes. Put the ownership read behind a worker-backed or batched SwiftDashSDK API, then recheck the refresh generation and container before publishing the resolved snapshot.
| private func identityMaxRefusal(_ prepared: PreparedExternalSend) async -> SendOutcome? { | ||
| guard prepared.route.source == .identity, prepared.isMax else { return nil } | ||
| guard let balance = await balances.spendableBalance(of: .identity), | ||
| AmountRules.check(amount: prepared.amount, source: .identity, balance: balance, fee: prepared.fee) == .ok |
There was a problem hiding this comment.
Resolved (re-reviewed at 3b676f07): Your new seam queries the prepared identity through refreshIdentityBalance, refuses a missing answer without using the app cache, and rechecks wallet and identity context after the await. The regression test leaves the stored balance high while lowering or removing the network answer.
| // A link naming two different apps to call back leaves which one open: it is refused like any invalid link. | ||
| guard let uri = BIP70URI(paymentUrlString), let requestURL = uri.r, !uri.hasConflictingCallback else { | ||
| throw DashSpendError.paymentProcessingError(NSLocalizedString("Invalid payment request", comment: "DashSpend")) |
There was a problem hiding this comment.
Resolved (re-reviewed at 3b676f07): Your fix in #1406 is present on this base: BIP70URI compares callback schemes without regard to case, and the DashSpend guard uses that result. The current tests cover both a mixed-case match and a genuine conflict.
3b676f0 to
f048f40
Compare
commented
Nov 26, 2026
|
Round on 3b676f0, now at f048f40 (rebased on develop 085182e, String Catalog as described on #1406):
|
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Nothing blocks: no blocking finding stands on this head.
Not counted: 2 disputed blocking finding(s) left to maintainers.
New on this head: This revision makes DashSpend reject malformed required amounts before fetching an invoice, applies the Core-to-Identity minimum to the asset-lock value, and uses the interactive HTTPS policy for payment-request sends. Recipient-aware Shielded History moved to #1501. Test-target membership, workflow lint, and accessibility checks passed; simulator tests and recovery are pending, and no funded end-to-end send was verified on this head.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — ExternalSendExecutor adds intricate prepare-and-broadcast routing across multiple spend paths, and ShieldedTransferCoordinator changes which recipient can receive funds when an asset lock is resumed. - 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.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
Not approved: 2 blocking finding(s) are disputed and left to the maintainers.
f048f40 to
1b6e065
Compare
commented
Nov 27, 2026
|
Round 12, head 1b6e065:
Harnesses green: identity top-up 15/15, asset-lock recovery 31/31, core drain 27/27. |
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Nothing blocks: no blocking finding stands on this head.
Not counted: 2 disputed blocking finding(s) left to maintainers.
New on this head: This revision includes the built BIP70 transaction’s miner fee in the spend-authentication amount and lets DashSpend accept repeated request URLs through the shared parser. On the reviewed head, recovery, test target membership, workflow lint, and accessibility checks passed; simulator tests were still running.
🟡 1 suggestion(s)
Follow-up candidates (optional) (1)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: A repeated request URL can make DashSpend fetch the wrong invoice
Impact: A gift-card buyer can pay a different invoice at the approved amount if the provider’s link contains two canonically equivalent Unicode URLs that the server routes separately.
DashWallet/Sources/Models/Transactions/SendCoinsService.swift:128-129
DashSpend can fetch the optional r invoice instead of the one specified by req-r. The previous reviewed head rejected repeated request fields; this head accepts them when the shared parser counts only one distinct value. BIP70URI counts decoded values in a Set<String>, which treats composed and decomposed Unicode as equal, but replaces r with the URL from each occurrence. A server can distinguish the resulting UTF-8 bytes in its path or query. The gift-card flow checks the fetched invoice’s amount, not whether it came from the required URL. Compare decoded request values byte-for-byte in the shared parser and add a regression that rejects a byte-distinct pair before fetching while still accepting identical repeats.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: general, security-auditor)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — ExternalSendExecutor.swift adds intricate preparation and confirmation logic across multiple funds-movement routes, while ShieldedTransferCoordinator.swift changes how recovery determines who receives locked funds. - 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)
- New since the last final review (
f048f40a): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 not confirmed (no longer blocking); 1 suggestion(s) on unchanged code listed as follow-up candidates - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); 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/ExternalSendExecutor.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Payments/ExternalSend/Services/ExternalSendExecutor.swift:795-799: BIP70 preparation signs the transaction before spend authentication
Impact: A holder who declines the new BIP70 spend prompt prevents submission, but the wallet has already signed the transaction and temporarily reserved its inputs.
Declining spend authentication no longer prevents signing. The new external-send service takes a verified, fundable Core payment request through `buildForSend`, which calls `SwiftDashSDKWalletSending.buildSignedTransaction` and reaches the SDK’s `finalizeAtomic`. That operation reserves the inputs and signs the transaction before `authorize(debit)` runs. Refusal releases the claim and discards the transaction; only the later Confirm action can POST or broadcast it. No shipped screen calls this executor on this head, but the new service reverses the send boundary documented in `AGENTS.md`: authenticate → build and sign → confirm → broadcast. Preserve the fee-inclusive biometric check by authorizing an unsigned SDK quote or an enforceable debit bound before signing, then reject any built debit above what was authorized. Add a refusal test that asserts the signer was never called, not just that nothing was broadcast.
_Raised as blocking. An independent pass did not find a failure someone would actually hit, so it does not block: The range-diff confirms that this revision moved BIP70 signing ahead of spend authentication: buildForSend reaches finalizeAtomic before authorize receives the fee-inclusive debit. That reverses the documented send order, but the executor is internal and has no production caller at this head; the existing interactive and headless BIP70 flows do not take this path. If authorization is refused, preparation resets the request claim and drops the SDK handle, releasing the input reservation without returning an action that can POST or broadcast. Fix the ordering before wiring the new Send screen._
Not approved: 2 blocking finding(s) are disputed and left to the maintainers.
| let built = try await service.buildForSend(confirmation) | ||
| do { | ||
| let (debit, overflow) = confirmation.amount.addingReportingOverflow(built.prepared.fee) | ||
| guard !overflow else { throw ExternalSendError.feeUnavailable } | ||
| try await authorize(debit) |
There was a problem hiding this comment.
✅ Withdrawn at
b21f18d0; see the replies below.
🟡 Suggestion: BIP70 preparation signs the transaction before spend authentication
Impact: A holder who declines the new BIP70 spend prompt prevents submission, but the wallet has already signed the transaction and temporarily reserved its inputs.
Declining spend authentication no longer prevents signing. The new external-send service takes a verified, fundable Core payment request through buildForSend, which calls SwiftDashSDKWalletSending.buildSignedTransaction and reaches the SDK’s finalizeAtomic. That operation reserves the inputs and signs the transaction before authorize(debit) runs. Refusal releases the claim and discards the transaction; only the later Confirm action can POST or broadcast it. No shipped screen calls this executor on this head, but the new service reverses the send boundary documented in AGENTS.md: authenticate → build and sign → confirm → broadcast. Preserve the fee-inclusive biometric check by authorizing an unsigned SDK quote or an enforceable debit bound before signing, then reject any built debit above what was authorized. Add a refusal test that asserts the signer was never called, not just that nothing was broadcast.
Raised as blocking. An independent pass did not find a failure someone would actually hit, so it does not block: The range-diff confirms that this revision moved BIP70 signing ahead of spend authentication: buildForSend reaches finalizeAtomic before authorize receives the fee-inclusive debit. That reverses the documented send order, but the executor is internal and has no production caller at this head; the existing interactive and headless BIP70 flows do not take this path. If authorization is refused, preparation resets the request claim and drops the SDK handle, releasing the input reservation without returning an action that can POST or broadcast. Fix the ordering before wiring the new Send screen.
source: gpt-6.2-astra (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Declining this one; the order is deliberate (round 12: the prompt must cover the amount plus the real fee).
- Signing here is local. A refused prompt resets the request guard and the dropped build handle releases the reserved inputs; nothing is POSTed or broadcast before Confirm (
sendAction). - The prompt is a spending-limit gate, not a key unlock:
finalizeAtomicsigns without it on every send path, so signing first exposes nothing that signing after would not. - The mechanism asked for does not exist:
CoreTransactionBuilderoffers onlyfinalizeAtomic/finalizeSignedPayment, both select, reserve and sign in one call; there is no unsigned quote. Authorizing a pre-built bound fromestimatedFee(recipientCount:)(one-input assumption) and rejecting any larger debit would refuse every multi-input invoice. - AGENTS.md's auth → build order describes
WalletSendService(whose prompt does not cover the fee). An unsigned select-and-quote in the SDK would let both paths authorize amount + fee before signing; that is an SDK follow-up, not this stack.
There was a problem hiding this comment.
Withdrawn (re-reviewed at b21f18d0): You're right that the WalletSendService ordering does not make the PIN a signing-key unlock. I verified that refusal exits before the POST/broadcast closure is created and that the pinned SDK drops the input reservation with the local handle; the SDK has no unsigned quote, and the current one-input estimate is not a safe debit bound.
…equest checks The services behind the new external send, with no screen calling them yet: an executor that prepares and sends every source and destination pair over the existing spend paths, a fee estimator, an Identity lookup that does not block the main actor, and a fetcher for dash: payment requests. A Core payment to someone else's Platform address is not offered: its recovery after a crash needs the recipient recorded with the asset lock, which the SDK does not do yet (dashpay/platform#5824). A BIP70 payment the merchant acknowledged before the broadcast failed, or before the request expired, is reported as in progress rather than not sent. Shared helpers the executor reuses: the identity top-up from Platform or Shielded credits moves out of the profile sheet, the Unicode-name spelling of merchant text is shared by both Sends, and the restore-sync gate of a Core spend can be observed. Co-Authored-By: Claude Opus 5.5 <[email protected]> SDD-Published-From: 64cd1001597fd96dd59c0f83796bb8763f53ec74
1b6e065 to
b21f18d
Compare
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Nothing blocks: no blocking finding stands on this head.
Not counted: 2 disputed blocking finding(s) left to maintainers.
New on this head: The rebased services commit adds a BIP70 regression test for request URLs that compare equal as Swift strings but have different UTF-8 bytes. The parser change is in the updated base: it rejects byte-distinct requests and still accepts byte-identical repeats. Recovery, test-target membership, workflow lint, and accessibility checks passed; the simulator suite is pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — ExternalSendExecutor.swift adds intricate preparation and confirmation logic across multiple funds-movement routes, while ShieldedTransferCoordinator.swift changes how recovery verifies the recipient before resuming a funded transfer. - 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.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
Not approved: 2 blocking finding(s) are disputed and left to the maintainers.
| let built = try await service.buildForSend(confirmation) | ||
| do { | ||
| let (debit, overflow) = confirmation.amount.addingReportingOverflow(built.prepared.fee) | ||
| guard !overflow else { throw ExternalSendError.feeUnavailable } | ||
| try await authorize(debit) |
There was a problem hiding this comment.
Withdrawn (re-reviewed at b21f18d0): You're right that the WalletSendService ordering does not make the PIN a signing-key unlock. I verified that refusal exits before the POST/broadcast closure is created and that the pinned SDK drops the input reservation with the local handle; the SDK has no unsigned quote, and the current one-input estimate is not a safe debit bound.
Issue being fixed or feature implemented
Second part of the new external Send for MO-1121: the services that send over the wallet's existing spend seams. No new way of spending money. ADR-0037 (added in #1409)
What was done?
ExternalSendExecutor: authenticates and prepares on Continue (Core → Core and BIP70 are built and signed there), sends on Confirm, and reports one of three outcomes; every route goes through the existing seams (WalletSendService,SwiftDashSDKTransactionSender, the Platform/Shielded coordinators, the identity top-up and credit paths). Core-funded sends are refused during a restored wallet's initial sync and run inside the asset-lock funding lifecycle.ExternalSendFeeEstimator: the fee per route; exact where the send is prepared, marked as an estimate where Platform meters it. [ADR-0043] (added in feat(wallet): new Send screens and entry points #1409)IdentityLookupService: an Identity ID → found / own / not found / could not check.CoreFundingResumer), the transaction details offer no Retry for such a lock, and the records are cleared on wipe.No screen calls these services yet; they arrive with the screens in #1409. Stacked on #1406.
Stack
This replaces the single PR #1358 (+21k lines), split by layer so each part can be reviewed and merged on its own. Merge in order:
chore(l10n): drop unused keys and sort the catalogs as BartyCrouch writes them (keeps the diffs below clean)How Has This Been Tested?
dashwallet-dashpay, Debug, iPhone 17 simulator (iOS 26.5): 2586 tests, 0 failures, 1 skipped;scripts/test_core_drain.pygreen.ExternalSendExecutorTestsover fakes and the real coordinator up to the SDK edge (incl. an external Core → Platform send reachingfundExternalFromCorewith the recipient's address),ExternalSendFeeEstimatorTests,IdentityLookupServiceTests,ExternalPlatformFundingResumeTests,ShieldedResumeRecipientTests, the BIP70 cases inPaymentProtocolTestsBIP70PaymentService: run the existing payment-link regression flows on this build.Breaking Changes
None. No schema change, no migration;
.platform-refunchanged.Checklist:
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes