Skip to content

feat(swift-sdk)!: read Rust's payment class on every PlatformWalletError - #6380

Merged
romchornyi merged 34 commits into
v5.2-devfrom
feat/platform-wallet-payment-delivery-swift
Dec 3, 2026
Merged

romchornyi merged 34 commits into
v5.2-devfrom
feat/platform-wallet-payment-delivery-swift

Conversation

@romchornyi

@romchornyi romchornyi commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Part of #5926. Whether a failed payment may have left the wallet was decided by every host from lists of error codes (Swift, Kotlin isRetryable, the apps), with different defaults per platform, while rs-platform-wallet already knows it and kept it crate-private (BroadcastDelivery). Rust now owns the answer; FFI, JNI, Swift and Kotlin only carry it.

Stack

This is part 3 of 4 of #5928, split for review (about 3–5k lines each). Each part builds and tests on its own base and is safe to merge into v5.2-dev alone; merge them in order.

# PR Part
1 #5928 Rust core: the payment class, the funded-lock seam and the flows built on it
2 #6379 The remaining wallet paths, and the FFI result carrying the class
3 #6380 Swift SDK and SwiftExampleApp
4 #6381 JNI, Kotlin SDK, KotlinExampleApp and the SDK parity manifest

What was done?

  • Swift: PlatformPaymentDelivery { notSent, maybeSent, lockHeld(AssetLockBuiltOutPoint) } and PlatformPaymentClass (class and retry). Every PlatformWalletError case carries payment: PlatformPaymentClass?, which init(result:) fills from the result's own payment_delivery, held_asset_lock and retryable, never from the code. payment, delivery and isRetryable read it, so Swift and Kotlin report the same class and retry for every result.

Open points for review

  • SwiftExampleApp: payment screens (Send, registration, identity top-up, asset-lock funding, seed pool, DPNS marketplace, invitation create) present a failure through one helper (PaymentFailure): MaybeSent, LockHeld or an unclassified payment failure holds the form, any NotSent releases it, LockHeld offers the resume of its named lock (an invitation's voucher is reclaimed).
  • Since the last review of feat(platform-wallet): report whether a failed payment may have left the wallet #5928: a failed Max transfer (wallet drain) keeps Rust's class and its Resume names the lock it resumes; guards after a paid write that succeeded (DPNS give-up, contract fee claims, moderation, token balance map) carry .maybeSent.

How Has This Been Tested?

  • DashSDKFFI.xcframework rebuilt (build_ios.sh --target sim). SwiftExampleApp WalletDrainRecoveryTests, ShieldedFundFromAssetLockCoordinatorTests, PaymentFailureTests: 95 passed.
  • SwiftDashSDK unit tests: 1300, with 26 Keychain failures (status -34018 on the local simulator, outside this change); ContractFeeClaimDecodingTests and MasternodesByVotingKeyTests pass. The full suite runs in CI.

Breaking Changes

  • Swift source: CoreTransactionBroadcastOutcome.rejected and .unknown gain a trailing payment: PlatformPaymentClass? = nil (Rust's class for the broadcast). Construction with two arguments still compiles; a pattern that binds them positionally needs a third element, e.g. .unknown(let txid, let reason, _) or .rejected(_, let reason, _).
  • Host-raised failures carry no class: a refusal Swift or Kotlin raises without calling Rust (the shielded Clear guard while another operation holds the lifecycle) has no payment/delivery and is not retryable. Swift guards that throw after Rust returned success but no output keep .maybeSent.
  • Swift source: every PlatformWalletError case gains a trailing payment: PlatformPaymentClass? = nil (class and retry). PlatformWalletError(result:) fills it from the result's own fields, never from the code.
    • A pattern that binds a case's values needs one more _, e.g. .invalidHandle(let m, _).
    • A case used as a (String) -> Error function must be wrapped in a closure.
    • A case Swift throws itself without a result is unclassified unless the thrower passes a class; the defaults are no longer .maybeSent.
    • New PlatformWalletError.payment, .delivery and .isRetryable. ShieldedIdentityCreateUnconfirmedError gains payment, delivery and isRetryable.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

🤖 Generated with Claude Code

PR Hygiene · 8785c53

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Summary by CodeRabbit

  • New Features
    • Payment errors now indicate whether a payment was not sent, may have been sent, or is associated with a held asset lock, with retry guidance when available.
    • The example app provides payment-specific recovery details, supports resuming the matching asset lock, and offers a confirmed option to release eligible holds after reviewing transaction history.
  • Bug Fixes
    • Missing or unreadable results after payment operations are marked as potentially sent, helping prevent duplicate submissions.
    • Uncertain outcomes remain visible and can block new submissions until resolved; alerts no longer imply an unconfirmed payment definitely succeeded or failed.

romchornyi and others added 5 commits November 28, 2026 02:49
…the wallet

Every wallet error now carries a payment class set once in Rust:
`NotSent` (nothing left the wallet, retryable as Rust decides),
`MaybeSent` (a dispatch happened; do not retry), or `LockHeld` (an
asset lock exists and names the outpoint its resume can finish).

This first part of the split of #5928 holds the class itself
(`PaymentDelivery`, `PlatformWalletError::payment_class`/`is_retryable`),
the funded-lock seam (`with_funded_lock`) that names a held lock on every
failure after it exists, and the flows built on that seam: identity
registration, invitation create and claim (with the SDK's
`InvitationError` now saying whether a claim was broadcast), the Platform
address and shielded fundings from an asset lock, and the external
identity top-up from addresses. The FFI only adapts to the new variant
shapes here; carrying the class to the hosts follows in the next PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-class wrapper

Until the FFI carries the payment class (next PR of the stack), the
blanket conversion and every result mapper read the error a
RefusedBeforeDispatch or PaymentAlreadyDispatched wraps, so its own code,
JSON detail and consensus code still reach the host.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… never sent

The drain records NotSent for a refusal before any lock exists; its error
now says NotSent too (before_dispatch) instead of MaybeSent. A
RefusedBeforeDispatch is never retryable, and its docs say so: its source
is a variant that also ends dispatched payments, so running the call
again is the user's decision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
refuses_resume read only the outer variant with matches!, so a new
variant took the false arm silently. It now reads through the
payment-class wrappers and names every PlatformWalletError variant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lback fails

The InstantSend claim before the fallback may have been sent, so any
fallback failure, a local one before its own broadcast included, now
arrives as StateTransitionResultUnconfirmed rather than a never-sent
error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The Swift SDK now carries payment-delivery and retryability classifications through wallet results and errors. The example app uses those classifications to present structured failures, restrict fresh submissions, resume matching asset locks, and release eligible payment holds.

Changes: Payment classification and recovery

Layer / File(s) Summary
Payment-class contract and propagation
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift, packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift, packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/*, packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift, packages/swift-sdk/Sources/SwiftDashSDK/FFI/SDK+IdentityPublicKeys.swift, packages/swift-sdk/SwiftTests/*
Adds payment-delivery and retryability types to wallet results and errors. Wallet operations and Core broadcasts propagate classifications, and paid-output decoding marks deserialization failures as .maybeSent. Tests cover classification propagation and updated error patterns.
Failure policy and controller lifecycle
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/PaymentFailure.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/*, packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/PaymentFailureTests.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletDrainRecoveryTests.swift
Adds recovery, slot-retention, and restart rules. Registration and funding controllers accept resume outpoints and restrict retries, dismissal, and release according to the stored failure.
Payment-aware screens and interactions
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/*, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/*, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/*, packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/*
Send, top-up, invitation, marketplace, and asset-lock screens display structured failures and gate fresh payments. Release actions require confirmation where reconciliation is permitted. Tests cover payment-class outcomes and hold behavior.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant WalletSDK
  participant PaymentFailure
  participant FundingCoordinator
  participant PaymentScreen
  WalletSDK->>PaymentFailure: Provide payment class and error detail
  PaymentFailure->>FundingCoordinator: Apply restart or resume policy
  FundingCoordinator->>PaymentScreen: Return controller state and failure
  PaymentScreen->>FundingCoordinator: Request release after confirmation
Loading

Possibly related issues

  • dashpay/platform#6137 — The change updates registration payment-failure handling in the same flow as the issue. The issue’s specific code 91 terminal-phase behavior is not established as fixed here.
  • dashpay/platform#5926 — The Swift SDK and example app use not-sent, maybe-sent, and held-lock classifications from Rust.
  • dashpay/platform#6009 — The change extends payment-class handling to additional Swift screens, including token configuration and contract updates. Other issue items remain outside this change.

Possibly related PRs

  • dashpay/platform#5853 — Both changes update the PlatformWalletError contract. This change adds optional payment-class values to its cases.
  • dashpay/platform#6379 — This change reads the payment-delivery and held-lock fields added by that PR.

Suggested reviewers: quantumexplorer, llbartekll, zocolini, shumkov

Merge Risk: Moderate · previous review 1be87

This example-app change still has open payment-hold gaps. A held registration can be lost on a network switch, a classless held drain failure shows a Resume that cannot run, and a released registration can fund the same identity index twice. Some progress screens also point to a Dismiss button that is no longer shown. Address or explicitly accept these before merging; the claim-hold race is fixed.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: every PlatformWalletError case now reads and carries Rust's PlatformPaymentClass. The raw summary confirms this: each error case gains an optional payment parameter, a…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: every PlatformWalletError case now reads and carries Rust's PlatformPaymentClass. The raw summary confirms this: each error case gains an optional payment parameter, and Swift exposes payment, delivery and isRetryable. The title is specific and concise, and the '!' marks a breaking change, which the objectives also describe through source-breaking pattern matches. The changeset also contains SwiftExampleApp payment-failure UI work, which the title does not mention, but that work follows from the same classification and is secondary to the SDK change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

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

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

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7c9421a and 1be87ea.

Files selected for processing: 3

  • packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/Tokens/TokenActions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/MasternodeDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenActions/TokenConfigChangeForm.swift

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@thepastaclaw

thepastaclaw commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 8785c53) · triage: critical

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (queue backlog)

Changes requested: 7 blockers

  • An unclassified wallet result is treated as if no payment was attempted — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/PaymentFailure.swift:63-68 (new)
    Impact: A paid operation that crosses the FFI with unknown delivery can be retried after the original call may already have reached the network, causing duplicate payments or duplicate funded operations.
  • The Swift SDK turns Rust payment metadata into retry and resume policy — packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:761-789 (new)
    Impact: Swift SDK consumers receive host recovery decisions and presentation text from binding-layer code, allowing payment retry or resume policy to diverge from the Rust-owned wallet state machine and other language bindings.
  • Marketplace actions remain submittable after an ambiguous payment failure — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DpnsMarketplaceView.swift:625-631 (new)
    Impact: After a purchase, listing, delisting, or transfer may have reached Platform, dismissing the alert leaves the same action sheet able to submit another paid transition.
  • An ambiguous invitation failure can fund a second voucher — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/CreateInvitationSheet.swift:255-260 (new)
    Impact: If invitation creation may have funded a voucher but failed to return its URI, the user can retry from the same sheet and leave another voucher funded while the first remains unresolved.
  • Address-funded identity registration re-enables after a possibly sent result — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/CreateIdentityView.swift:1417-1422 (new)
    Impact: A failed address-funded registration that may have reached Platform leaves the Create Identity form active, allowing another paid registration attempt for the same identity slot.
  • Platform-to-shielded failures lose their payment hold when the sheet closes — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ShieldedFundFromAssetLockView.swift:832-838 (new)
    Impact: A platform-balance shield classified as possibly sent can be dismissed and started again from a newly opened sheet, potentially shielding the same credits twice.
  • Identity top-up loses its payment hold when the view is cancelled — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TopUpIdentityView.swift:791-803 (new)
    Impact: After a maybe-sent or unclassified top-up, cancelling the pending screen and reopening it allows another top-up even though the original operation is unresolved.

This PR propagates Rust-owned payment-delivery metadata through the Swift SDK and updates SwiftExampleApp payment flows to present recovery guidance. The Kotlin SDK build check failed in an unrelated Kotlin authentication test; no Swift-specific CI failure is reported.

🔴 7 blocking | 🟡 1 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: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 8: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate change across Swift wallet error handling and recovery flows that directly affects funds movement and asset-lock recovery semantics, particularly in PlatformWalletResult.swift and the wallet drain, funding, registration, and payment-failure coordinators.
  • Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/PaymentFailure.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/PaymentFailure.swift:63-68: An unclassified wallet result is treated as if no payment was attempted
  Impact: A paid operation that crosses the FFI with unknown delivery can be retried after the original call may already have reached the network, causing duplicate payments or duplicate funded operations.
  The `Unknown` FFI delivery explicitly means that no wallet error established whether funds left the wallet, but `PlatformWalletResult.paymentClass` maps it to `nil` and this helper then returns `nil` for every `PlatformWalletError` without a class. Callers consequently treat the error as an ordinary pre-payment failure, clear their in-flight state, and allow a new submission. Preserve an explicit unclassified payment failure for payment-operation callers, or pass operation-attempt context so only errors proven to occur before the payment call are treated as safe non-payment errors.

In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:761-789: The Swift SDK turns Rust payment metadata into retry and resume policy
  Impact: Swift SDK consumers receive host recovery decisions and presentation text from binding-layer code, allowing payment retry or resume policy to diverge from the Rust-owned wallet state machine and other language bindings.
  The public `PlatformPaymentRecovery` type decides whether the host should retry, wait, reconcile, or resume and supplies the corresponding user-facing guidance. Although it currently derives those values from Rust's fields, this is still payment-operation policy in the Swift SDK rather than a faithful transport of the Rust result. The project layering rule requires Swift and FFI wrappers to marshal Rust-owned decisions rather than decide whether to retry, rebuild, or replay an operation. Keep the SDK types as mirrors of delivery, retryability, and the held outpoint, and move recovery/action presentation to the application or another host-owned layer.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DpnsMarketplaceView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DpnsMarketplaceView.swift:625-631: Marketplace actions remain submittable after an ambiguous payment failure
  Impact: After a purchase, listing, delisting, or transfer may have reached Platform, dismissing the alert leaves the same action sheet able to submit another paid transition.
  The catch creates `PaymentFailure` only to render the alert, then resets `isSubmitting`; the confirmation button is disabled only by `!canSubmit || isSubmitting`. `confirmed` remains unset, so dismissing the alert re-enables the same action even for `.maybeSent`, `.lockHeld`, or an unclassified result. Retain the failure as terminal action-sheet state and gate confirmation and dismissal until reconciliation or the exact permitted lock resume; only a Rust-approved `.notSent` result should release the form.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/CreateInvitationSheet.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/CreateInvitationSheet.swift:255-260: An ambiguous invitation failure can fund a second voucher
  Impact: If invitation creation may have funded a voucher but failed to return its URI, the user can retry from the same sheet and leave another voucher funded while the first remains unresolved.
  The `defer` resets `isCreating` after every failure, and the submit button is disabled only by `isCreating` and amount validity. The new code stores only `PaymentFailure.message`, so a `.maybeSent`, `.lockHeld`, or unclassified result loses its hold as soon as the alert text is dismissed. Store the payment failure or an equivalent operation guard and keep the form blocked until the voucher is reclaimed or reconciled; only a proven `.notSent` result may release it.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/CreateIdentityView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/CreateIdentityView.swift:1417-1422: Address-funded identity registration re-enables after a possibly sent result
  Impact: A failed address-funded registration that may have reached Platform leaves the Create Identity form active, allowing another paid registration attempt for the same identity slot.
  This direct `registerIdentityFromAddresses` path bypasses the existing registration coordinator. Its catch converts the payment classification into a temporary `SubmitError` and sets `isCreating` to `false`; `canSubmit` has no retained payment hold. Dismissing the alert therefore permits another submission even when Rust classified the original result as `.maybeSent`, `.lockHeld`, or unclassified. Route this path through the registration coordinator or retain the payment failure and identity-slot guard until reconciliation, releasing it only for a Rust-approved `.notSent` result.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ShieldedFundFromAssetLockView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ShieldedFundFromAssetLockView.swift:832-838: Platform-to-shielded failures lose their payment hold when the sheet closes
  Impact: A platform-balance shield classified as possibly sent can be dismissed and started again from a newly opened sheet, potentially shielding the same credits twice.
  The platform branch converts `PaymentFailure` into `PlatformShieldPhase.failed(title:message:)`, retaining no delivery class or operation guard. The toolbar becomes dismissible as soon as the call leaves `.inFlight`, and dismissing the sheet destroys the phase; the next presentation starts at `.idle` and `canSubmit` allows a fresh shield. Retain this operation through the wallet/coordinator or persist an equivalent reconciliation gate so reopening the screen cannot initiate a second payment after an ambiguous result.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TopUpIdentityView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TopUpIdentityView.swift:791-803: Identity top-up loses its payment hold when the view is cancelled
  Impact: After a maybe-sent or unclassified top-up, cancelling the pending screen and reopening it allows another top-up even though the original operation is unresolved.
  The view stores the failure only in local `@State`; `.maybeSent` switches to `isPending`, and the Cancel button is re-enabled once `isToppingUp` becomes false. Dismissing the view destroys both the pending and failure state, while the wallet-level pending rows shown below do not gate a new address-funded top-up. Keep the unresolved operation in a wallet-level coordinator or persisted pending record and make re-entry consult that owner before allowing another submission.

In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift`:
- [SUGGESTION] packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift:397-411: Read-only network failures lose their normal retry guidance
  Impact: SDK users performing ordinary queries or other non-payment requests receive a non-retryable error for every network failure or timeout, even though those operations have no payment-delivery ambiguity.
  This shared formatter now hard-codes `isRetryable: false` for every `SDKError.networkError` and `.timeout`. Those same error types are produced by read-only SDK operations, where the generic retry suggestion remains appropriate; the formatter has no operation context with which to apply a payment-specific fail-closed policy. Restore the category-based behavior here and apply conservative payment handling only in payment-operation owners or a payment-specific presentation helper.

@romchornyi
romchornyi force-pushed the feat/platform-wallet-payment-delivery-swift branch from cf107e7 to ccc37aa Compare November 28, 2026 03:15
@romchornyi

Copy link
Copy Markdown
Contributor Author

Rebased onto #6379's 89e8075 (the FFI's own send refusals now cross as Unknown); no change to this PR's own diff. The fix commits named in the thread replies are now:

romchornyi and others added 16 commits November 28, 2026 06:27
The ChainLock fallback's error is wrapped as unconfirmed, which hid
Platform's consumed-outpoint verdict from the adoption check, so a claim
whose InstantSend primary had landed reported a failure instead of its
identity. The check now reads the verdict through the wrapper and keeps the
wrapper when nothing is adopted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ror to the hosts

Second part of the split of #5928, on top of the payment class itself.
The remaining wallet paths now set their class (DPNS and the
marketplace, contact requests, credit and token shielded spends and
plans, shielded tips, the shielded seed batch and the wallet drain,
masternode withdrawals), and every FFI result carries Rust's class:
`payment_delivery`, `retryable` and the held asset lock's outpoint on
`PlatformWalletFFIResult`, set from the wallet error by the blanket
conversion and every result mapper, never inferred from the code. A
panic in a payment export is classed as possibly sent.
ERROR_CODE_REGISTRY.md documents the class per code. Swift and Kotlin
read it in the next two PRs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ever sent

The mainnet gate, the wallet id check, the starting notes count, the
recipient and the first batch's fee and amount refuse the run before any
lock is built, so they are NotSent (before_dispatch); after an earlier
batch dispatched they stay the run's MaybeSent failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…esults

PlatformWalletFFIResult gains payment_delivery, held_asset_lock and
retryable in this PR, so Swift's init(code:message:) fills them with
Rust's own defaults and the test that builds a result field by field
names them; Swift reads them in the next PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…assified

A null pointer, an invalid handle, a different or removed wallet generation
and an unrepresentable txid are refused by the FFI, not by a wallet error;
they crossed with a class stamped from a wallet error made up for the call.
They now cross as Unknown, as the result's contract says.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Third part of the split of #5928. `PlatformWalletError` carries the FFI
result's `PlatformPaymentClass` (delivery, retry, and the held asset
lock under `LockHeld`) on every case, read from the result and never
derived from the code; texts and recovery suggestions follow it, and a
guard that throws after a successful FFI call carries a class too.
SwiftExampleApp presents a payment failure by its class: it holds a
payment's slot unless nothing was sent, names a held voucher or lock,
and releases a hold only once the user reconciled it.

BREAKING CHANGE: `PlatformWalletError` cases gain a `payment:` field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`PlatformWalletError.invalidParameter` now carries `payment:`, so the
single-binding catch pattern bound a tuple and the test target did not
compile. No other single-binding pattern over a `PlatformWalletError`
case remains in the Swift SDK, its tests or the example app.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every guard that throws after Rust reported a paid write as done now
carries `payment: .maybeSent`, including an output that does not decode:
the DPNS give-up result, the contract fee claim (missing JSON and its
decode), and every signed moderation call (missing JSON and its decode,
through `moderationCall`). The moderation offer read still carries no
class. `PlatformWalletError.readingPaidOutput` reclasses a decode refusal
of such an output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd name the lock its Resume resumes

A drain failure carries Rust's class, and the drain's own Resume names
the outpoint it resumes:
- `WalletDrainAttemptError` carries the class of the outcome's error
  (`attemptError`), `.notSent` for a not-sent outcome whose error has
  none, and keeps the class when a resume finds no tracked lock
  (`resumeError`). `PaymentFailure.paymentClass(of:)` reads it, so a
  not-sent drain releases its slot instead of holding it as unconfirmed.
- `run` passes `resuming:` to `startFunding`: `nil` for a start, the
  resumed outpoint from `resume`, so a failure that holds that lock lets
  the drain's Resume run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e voucher outpoint claim

The submit docs of the shielded and address funding controllers and the
identity registration controller said a slot restarts only after a
retryable failure; any `.notSent` failure releases it. The invitation
create comment said `out_outpoint` names the held voucher lock, but
nothing reads it: a success without a URI throws `.maybeSent`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…duled

A slot that holds a failed Max refuses a new one by re-presenting the
failure without running its body. `start` now removes the id it just
stored in that case too, as it does for a start blocked by another
funding, so a refused start leaves no marker behind.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aybe sent

Token transfer, burn and mint read the balances Rust returns through
`tokenReadingBalancesJSON` after the write succeeded; a map that does not
parse now throws `.deserialization` with `payment: .maybeSent`, like the
other guards after a paid write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The SDK marshals Rust's payment class (delivery, isRetryable, the held
lock) and no longer turns it into a recovery, a title or user-facing
text. `PlatformPaymentRecovery` and `ErrorRecovery.suggestion(for:
PlatformPaymentClass?)` are removed; the example app's `PaymentFailure`
now owns the same mapping as `PaymentFailure.Recovery`, with its
suggestion and invitation-voucher texts.

`ErrorCategorizer` / `ErrorFormatter` show a wallet error as its own
text, titled by its category, with Rust's retry and no suggestion. The
`.transactionBroadcastUnconfirmed` text and title are back to the base
branch's.

BREAKING CHANGE: `PlatformPaymentRecovery` and
`ErrorRecovery.suggestion(for: PlatformPaymentClass?)` are gone; a host
decides retry, wait or resume from `PlatformWalletError.payment`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`ErrorCategorizer` had started presenting every `SDKError.networkError`
and `.timeout` as not retryable with no suggestion. That is a decision
the SDK does not own, and it also hit read-only queries. The base
branch's category-based answer is back; a payment screen decides from
Rust's class in the app.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed payment

`PaymentFailure.ofPayment` returned nil for a `PlatformWalletError`
without a class, so the screen showed it as a plain refusal and let a
new payment go. The FFI's `Unknown` delivery also decodes to no class,
so a paid call can come back that way. As in Kotlin's
`PaymentFailure.ofPayment`, every SDK error is now a payment failure; a
classless one is unconfirmed and holds its slot until the user releases
it after checking the history. Only an error that is not an SDK error
(the screen's own input check) shows as its own message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r an unresolved failure

Every example-app screen that starts a payment now keeps its last
`PaymentFailure` and, while it holds its slot (`.maybeSent`, `.lockHeld`
or no class), refuses a fresh payment from that screen: the control is
disabled and the action itself checks `PaymentFailure.permitsFreshPayment`.
The failure clears only on a success, a later `.notSent` result, or the
user's confirmed release (`ReleasePaymentHoldButton`, offered when
`releasableAfterReconciliation`). `PaymentFailure.keptAfter` keeps a hold
across an error that is not an SDK error (← Kotlin).

Applied at:
- CreateInvitationSheet: create is refused while a voucher lock is held
  (its text sends the user to reclaim it under Sent invitations) or the
  create may have gone through.
- DpnsMarketplaceView: one screen-level trade failure gates list,
  delist, transfer and purchase (menu items and the sheet's confirm);
  search, sync and history stay available.
- TopUpAddressFromAssetLockViewModel / AddressQueriesView: the top-up
  button and `executeTopUp` are refused; a form reset keeps the hold.
- CreateIdentityView: the Platform-payment registration's failure is
  kept and gates submit before any key is persisted.
- SendViewModel: a rejected Core broadcast is read by its payment class
  like an unknown one, so a holding class keeps the form refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot removed the waiting-bots Waiting for the review bots to report on this head label Dec 3, 2026
romchornyi and others added 2 commits December 3, 2026 11:04
…eded

A reopened Erase sheet whose opening read failed showed the Erase button
(no lifecycle and no submission yet), so an operator following the
unknown-outcome alert could pay for the next chunk without seeing what
the first attempt left. Erase is now offered, and submit() accepted,
only once a lifecycle read succeeded; a failed read offers a read-only
"Read Lifecycle Again" instead. Rust still decides eligibility.

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

Copy link
Copy Markdown
Contributor Author

Re the suggestion not shown inline (thepastaclaw, DocumentsView.swift:888-896, "Reopening Erase allows another paid chunk before history is shown"): fixed in c36e196. Erase is offered, and submit() accepted, only after a lifecycle read succeeded (canSubmitAnother is false without a lifecycle); a failed read, the opening one or the closing read after a submission, offers a read-only "Read Lifecycle Again" instead. Rust still decides eligibility. The inline suggestion (contract fetch classed MaybeSent) is deferred to #6009 on its thread. Also merged the current v5.2-dev (3771724, no conflicts).

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw reviewed an earlier commit, not yet this one. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Dec 3, 2026

@thepastaclaw thepastaclaw left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

GitHub still shows changes requested by this bot (review of 7c9421a8). Nothing on this head blocks except the disputed finding(s) below, which are left to the maintainers: a maintainer can dismiss that earlier review if they agree it no longer applies.

Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.

New on this head: The latest commit makes the Swift example app's Erase sheet wait for a successful lifecycle read before offering a paid submission, and adds a read-only retry when the observation is unavailable. On this head, the Swift and Kotlin SDK builds and tests and the Swift frozen-schema check passed; PR Hygiene and the review check are pending.

🟡 2 suggestion(s)

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: architecture-layering); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

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

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift:900-902: Erase stays unavailable when the document's contract is missing from the SDK cache
  Impact: An operator with an erasable document saved locally cannot proceed from the Erase sheet if its custom contract was not loaded into the SDK, even when Platform is reachable.
  Tapping “Read Lifecycle Again” cannot recover from this cache miss. This commit makes the lifecycle read mandatory, but `dash_sdk_document_fetch_history` calls `wrapper.data_contract` before sending the history query, and the app's adaptive context provider resolves contracts only from its local cache or the built-in system contracts. A saved custom contract can be missing from that cache: startup skips rows without `binarySerialization` and continues after preload errors. The wallet's erase path already fetches and registers the contract before reading history. Keep the successful-read gate, and have the Rust SDK's history path fetch and register a missing contract for proof verification, with the FFI delegating to that path.
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift:1019-1024: Erase gives no reason when the required lifecycle read fails
  Impact: An operator on a network below protocol 15 or without an initialized SDK sees the same “Read Lifecycle Again” button as someone whose connection timed out.
  The operator cannot tell whether trying again will help. The history API preserves the protocol refusal and transport errors in `SDKError`, and `documentGetLifecycle` throws a serialization error if the lifecycle block is incomplete. The sheet's `try?` discards those diagnostics, while optional chaining turns an unavailable SDK into the same `nil`. Keep Erase disabled, show the read error next to the read-only retry, give an explicit message when the SDK is unavailable, and clear the message when a read succeeds.

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

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Dec 3, 2026
The read-only retry that replaces Erase after a failed lifecycle read gave
no reason, so a protocol refusal, a missing SDK and a timeout looked the
same. The sheet now shows the read's error next to the retry, says so
explicitly when the SDK is not initialized, and clears the message once a
read succeeds. Erase stays unavailable until then.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw reviewed an earlier commit, not yet this one. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Dec 3, 2026

@thepastaclaw thepastaclaw left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

GitHub still shows changes requested by this bot (review of 7c9421a8). Nothing on this head blocks except the disputed finding(s) below, which are left to the maintainers: a maintainer can dismiss that earlier review if they agree it no longer applies.

Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.

New on this head: The Erase sheet now explains why a lifecycle read failed, distinguishes an unavailable SDK, and clears the diagnostic after a successful read. Retrying is read-only, and the paid action still requires an observed deleted or erasing lifecycle. The Swift SDK build and tests, frozen-schema check, and Kotlin SDK build and tests passed; PastaClaw review and PR Hygiene were pending.

🟡 1 suggestion(s)

Still open from earlier rounds (1)

  • 🟡 Suggestion: Erase stays unavailable when the document's contract is missing from the SDK cache — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift:900-902 (thread)
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: architecture-layering); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

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

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift:900-902: Erase stays unavailable when the document's contract is missing from the SDK cache
  (carried; thread: https://github.com/dashpay/platform/pull/6380#discussion_r4783082371)

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

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Dec 3, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Dec 3, 2026
@romchornyi
romchornyi dismissed thepastaclaw’s stale review December 3, 2026 13:59

The one finding behind this review (paid token update losing its hold when Rust cannot return the receipt) is marked Disputed by the bot itself and fixed in #6464 (Rust handback class on every paid output, all layers). The bot reports nothing blocking on the current head 8785c53.

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving at 8785c53. Static review only (nothing built or run here).

The SDK side reads cleanly: the class comes only from the result's own fields, Unknown decodes to nil, an unrecognised delivery ordinal reads as .maybeSent, and the guards after a successful Rust call consistently carry .maybeSent. The disputed PastaClaw finding (Swift assigning .maybeSent in readingPaidOutput) is a layering inconsistency rather than a double-payment risk, since both a classless error and .maybeSent hold the form; fine to settle in #6464.

Two non-blocking notes on SwiftExampleApp, both on the conservative side (neither allows a second payment), so a follow-up is fine:

  1. A classless failure overwrites a held lock and leaves Resume dead. When a slot is .failed(lockHeld(X)) and the resume of X throws before Rust is asked (e.g. admitNativeOp during shutdown, or a parameter guard), the controller's catch replaces the phase with PaymentFailure(error), which is unconfirmed and has no heldLock. From then on permitsRestart(resuming: X) is false, so Resume X and Dismiss are both refused and the only exit is "Payment checked in history — release", for a payment that was never sent. Applies to the shielded, address and registration coordinators (ShieldedFundFromAssetLockController.submit, AddressFundFromAssetLockController, IdentityRegistrationController). No test has a classless failure following a .lockHeld one. Keeping the previous held lock when the new error carries no class would cover it.

  2. Address top-up: resuming a held lock to a different recipient may strand the original slot (not verified against Rust). FundFromAssetLockPlatformAddressView lets resume mode re-pick the account and recipient, while the coordinator's slot key includes the recipient. Resuming lock L to recipient B runs under a new key; slot A stays .failed(lockHeld(L)) with no Dismiss and no Release, and L is consumed, so A stays blocked until the app restarts. I only found the recorded-recipient check (AssetLockRecipientMismatch) on the shielded path, so I could not confirm whether Rust refuses this for platform addresses; if it does, this is moot.

@romchornyi

Copy link
Copy Markdown
Contributor Author

Thanks @llbartekll. Both notes are tracked in #6009 (#6009 (comment)) and will be fixed in a follow-up, not on this head. On the second one I checked Rust: funding owned Platform addresses records no recipients on v5.2-dev (only #5930 records them, for external addresses), so a resume to another own address is not refused and the original slot does stay blocked until restart, as you describe. No second payment either way.

@romchornyi
romchornyi merged commit c107643 into v5.2-dev Dec 3, 2026
31 checks passed
@romchornyi
romchornyi deleted the feat/platform-wallet-payment-delivery-swift branch December 3, 2026 15:30
romchornyi added a commit that referenced this pull request Dec 3, 2026
…tity-create-chargeable-failure

#6380 gave every PlatformWalletError case Rust's payment class. The
inputs-consumed identity create (code 91) takes it the same way: in the
case, its errorDescription and payment arms and the result-code mapping.
The every-case class test lists 91 among the header's codes, and the
typed-case test matches the new shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants