Skip to content

feat(swift-example-app): shielded tips to a DashPay contact or username - #6198

Merged
QuantumExplorer merged 46 commits into
v5.1-devfrom
feat/swift-example-shielded-tips
Nov 24, 2026
Merged

QuantumExplorer merged 46 commits into
v5.1-devfrom
feat/swift-example-shielded-tips

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does. Adds shielded tip screens to SwiftExampleApp. You can tip someone from a contact, or by typing a username on your own profile. The tip is paid from your identity's shielded balance to the shielded address that person published in their DashPay profile. The sheet shows what the wallet worked out:

  • the amount;
  • who the name pays;
  • whether that recipient differs from the one last confirmed for the name;
  • whether an earlier payment to them has not resolved yet.

Then it sends and shows the result.

Value. iOS gets the tip flow of #5288 on v5.1-dev, built on the wallet API of #6191 and #6192. The screens decide nothing. The wallet does all of it:

  • parses the amount;
  • picks the paying account (the identity's own, proved with the seed);
  • refuses a name that moved away from the contact you picked;
  • refuses a second tip while an earlier one is unresolved, including after the app is killed and relaunched.

That covers both items of #5674 on iOS.

Risks.

  • Example app only. No Rust, FFI, SDK, consensus or SwiftData change.
  • Nothing has been run on a simulator yet. The prebuilt framework lacks the new native symbols (see "Not yet verified").
  • You can only tip a contact if the device knows a username for them. Today that is the DPNS hint saved when the contact was added by username. For other contacts the button is off, with a note saying why.

Issue being fixed or feature implemented

Shielded tips for 5.1, the iOS app part. Built on #6191 (wallet and C FFI) and #6192 (SDK wrappers), both merged into v5.1-dev. Replaces the Swift half of #5711.

Addresses #5674 and #6200 for SwiftExampleApp:

  1. A restart can repeat a tip. The app keeps no "tip in flight" state of its own. After a relaunch, the wallet reports an unresolved earlier tip from the review (unresolved) and refuses the send with code 85. The sheet then offers only a shielded sync. When the refusal ends, it still never suggests sending again, because the earlier payment may have paid.
  2. A re-slot can change which account pays. The send passes .identity(identityId) for the identity you are acting as. The wallet proves that account with the seed inside the send.
  3. A contact's name can move to another identity (Shielded tip from a contact: check that the username still belongs to that contact #6200). A tip from a contact passes the contact's identity id to both the review and the send. The wallet refuses a name that now belongs to someone else with code 86.

The KotlinExampleApp screens are #6197, built from the same base, which mirrors the TEST_PLAN rows below.

What was done?

Views/DashPay/ShieldedTipFlow.swift (new). It maps wallet results to what the screen shows and adds no rules of its own:

  • ShieldedTipSendOutcome.of(error):
    • 18 / 20: "may have gone through".
    • 85: "earlier payment unresolved".
    • 86: "this name moved to another identity".
    • anything else: "not sent", with the wallet's message.
  • ShieldedTipAmount: what the wallet's amount parser returned, or its refusal.
  • ShieldedTipPresentation: the wording for each change kind (always "last confirmed for this name", never "last tip"), the unresolved caution, and the no-username note.
  • ShieldedTipBalanceState:
    • The identity balance: unverified, unavailable or available.
    • Each read is numbered, and only the latest one applies.
    • A busy store (shieldedBalanceBusy, code 87) keeps the last balance and reads again after 2 s. Every other error is shown, with no retry.
  • ShieldedTipFlow, the sheet's state machine:
    • The wallet calls are passed in as closures.
    • Any edit drops the review, and a review that finishes after an edit is discarded.
    • Send is offered only when the review is not unresolved.
    • After 18 / 20 / 85 the inputs lock and only a shielded sync is offered.

Views/DashPay/ShieldedTipSheet.swift (new):

  • ShieldedTipSheet(identity:username:contactIdentityId:) has these sections:
    • From: the identity and its balance.
    • To: the username.
    • Amount: the parsed amount, plus an optional memo.
    • Review: the recipient identity, the address rendered by Rust, and the change. A changed recipient shows as an orange warning with the previous recipient. An unresolved review shows the caution.
    • Actions: Send, the outcome, and "Sync shielded now".
  • ShieldedTipBalanceRow does every read through one task. It reads again after a sync, after a send, and after Prepare (prepareShieldedIdentityAddress).

Entry points:

  • ContactDetailView.swift: "Send shielded tip", which passes the contact's identity id.
  • DashPayProfileView.swift: a "Shielded tips" section with the balance row and "Tip a username", which passes no contact.

Accessibility identifiers are under dashpay.tip.*:

  • entry points, inputs, review fields and actions;
  • dashpay.tip.outcome.{submitted,mayHaveGoneThrough,pending,recipientMismatch,notSent};
  • dashpay.tip.balance*.

TEST_PLAN: rows DP-33 to DP-38 (Layer Shielded), a fixture row, updated tier and layer counts, the DashPay index line, and DP-35 added to the restart tag list.

Row Flow Tier
DP-33 Tip a contact or a username Common
DP-34 Review shows a changed recipient Uncommon
DP-35 Earlier payment unresolved (85), also after a relaunch (restart) Uncommon
DP-36 Tip that may have gone through (18 / 20) Uncommon
DP-37 Refused with nothing sent, including a contact's name that moved (86) Uncommon
DP-38 Identity balance states, Prepare, busy store and read errors Thorough

Parity manifest: a new capability dashpay.shielded_tips covering the four C exports.

Before and after

Before, on the base branch, the SDK had reviewShieldedTip and sendShieldedTip, but no screen called them. Contact detail had only the DashPay payment button.

After, contact detail → Send shielded tip:

Amount  [0,5        ]   → "0.5 DASH" (parsed by the wallet)
[Review]
  To       alice  ·  9fRY…  ·  <shielded address, rendered by Rust>
  Change   Same recipient as the one last confirmed for this name from this wallet.
[Send]
  ✓ Tip sent

A second tip to the same person while the first is unresolved, in the same session or after a relaunch:

before: (no screen)
after:  Review: "The wallet refuses a tip to this recipient for now. ... may pay them. Check
        shielded activity before tipping this recipient again", Send off, only "Sync shielded now".
        A send that races it: "Not sent: an earlier payment is unresolved" (85), inputs locked,
        only the sync offered; nothing sent.

A contact whose name now belongs to someone else:

after:  "Not sent: this name moved to another identity" (86). To tip the new owner, start from
        the name on your profile.

Public interface changes

None. Only these change:

  • SwiftExampleApp's internal views;
  • the TEST_PLAN;
  • the parity manifest, which gains one capability (dashpay.shielded_tips) and four shared_symbols;
  • the generated parity summary.

No SDK, FFI or SwiftData model changes, and no persisted format changes.

How Has This Been Tested?

  • ShieldedTipFlowTests (34 tests, new) cover:

    • each send outcome: 18, 20, 85, 86, 7, 6, and any other error;
    • locked inputs, with only a sync offered after 18 / 20 / 85;
    • the contact id passed to the review and the send, and none for a typed name;
    • each change kind, and the unresolved review keeping Send off;
    • review failures and stale reviews;
    • amount refusals;
    • the balance states, a busy store keeping the balance and reading again, other errors shown without a retry, Prepare staying off until a fresh read lands, and ignoring a stale read.

    All 34 pass on an iOS 17 simulator, and the existing ContactRequestOutcomesTests (32) pass too.

  • How the app was built for that run:

    • With xcodebuild build-for-testing against an older prebuilt DashSDKFFI.xcframework, using headers regenerated from this branch's FFI sources.
    • The static library lacks the tip symbols and eight other newer exports, so a stub object filled in those names.
    • The tests reach the wallet only through closures, so none of them calls a stub.
  • python3 scripts/check_sdk_parity_manifest.py: OK, 52 capabilities, summary current.

Not yet verified

  • build_ios.sh, and a link against the real tip symbols.

  • DP-33 to DP-38 on a simulator or device, including:

    • a funded tip;
    • a relaunch between broadcast and result (DP-35);
    • a contact whose name moved (DP-37).

    A separate QA pass does the device runs.

Breaking Changes

None.

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

QuantumExplorer and others added 4 commits November 24, 2026 06:59
…y the wallet

A tip is a shielded transfer to the shielded address a DashPay profile
publishes. The wallet now owns what a payment screen would otherwise
decide: the typed amount (parse_shielded_tip_amount), whom a name pays and
whether that changed since the wallet last paid it (review_shielded_tip),
which account pays (ShieldedTipSource, proved with the seed for an
identity), whether the tip may be sent (send_shielded_tip), and whether an
identity's shielded balance is known (shielded_identity_balance).

A tip is refused with ShieldedTipPending while another tip is being sent
and while an earlier transfer to the recipient may still execute. The
recipient of a saved transfer is read back from its signed transition with
the paying account's outgoing viewing key, so the refusal rests on the
record every shielded spend already saves before its first dispatch and
survives a restart.

C exports: platform_wallet_parse_shielded_tip_amount,
platform_wallet_manager_review_shielded_tip,
platform_wallet_manager_send_shielded_tip and
platform_wallet_manager_shielded_identity_balance. Result code 84
(ErrorShieldedTipPending), mirrored in Swift and Kotlin.

Rebuilt on v5.1-dev from the design of #5288 and #5709.

Co-authored-by: pasta <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Swift (PlatformWalletManagerShieldedTips.swift) and Kotlin
(PlatformWalletManager, ShieldedTip.kt, through the JNI bridge in
funding.rs) wrappers over the four shielded tip exports:
parseShieldedTipAmount, reviewShieldedTip, sendShieldedTip and
shieldedIdentityBalance. They convert types and throw the typed error;
the wallet decides everything.

Rebuilt on v5.1-dev from the design of #5288 and #5709.

Co-authored-by: pasta <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
- Kotlin `sendShieldedTip` runs under `opReturningCompletedResult`, as the
  other calls that move funds do: native code cannot see a coroutine's
  cancellation, so a tip sent after it must not read as cancelled.
- Swift refuses text holding a NUL before the native call (amount,
  username, memo): a C string ends at its first NUL, so Rust would judge
  only the prefix. The JNI bridge already refuses it.
- The JNI blob encoders match the two C enums in full, so a new case does
  not compile until it has a tag and a Kotlin decoder branch.
- Swift tests for the review and balance decoders and the NUL refusal.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Tip sheet on contact detail and on the own profile: amount parsed by the
wallet, review of the recipient the wallet resolved, send from the
identity's own shielded account, and the outcomes the wallet reports
(sent, may have gone through, earlier tip pending, not sent). Adds
TEST_PLAN DP-33..38 and the dashpay.shielded_tips parity entry.

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

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next included review available in 58 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 02ff8f7 and 3835f17.

Files selected for processing: 8

  • docs/sdk/sdk-parity-manifest.json
  • packages/kotlin-sdk/PARITY_SUMMARY.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/DashPayProfileView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipFlow.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSheet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ShieldedTipFlowTests.swift
  • packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Share

QuantumExplorer and others added 2 commits November 24, 2026 08:01
From review:
- A bind that would drop or re-key the account an unresolved note spend
  was paid from is refused, as it was for an identity-funded shield:
  dropping the account dropped the spend's record, and with it the
  refusal of a second tip to the same recipient.
- A tip is admitted before its seed is resolved
  (PlatformWallet::admit_shielded_tip, passed to send_shielded_tip), so a
  second request cannot wait in a slow mnemonic lookup and pay again.
- The outputs read back from a saved transfer must hash to the id it was
  saved under: a payment that no longer opens while its change does now
  blocks instead of reading as "pays nobody".
- A tip to an address of the account it is paid from is refused.
- The paying account is settled again after the network lookups.
- A review and an identity balance are read on the coordinator the wallet
  is bound on.
- The three exports that block on the runtime refuse a call made from a
  callback the library invokes, instead of panicking there.
- The shielded sync requested after an unconfirmed tip is requested by
  the manager (ShieldedTipSender), not by the C export.

A test builds and proves a real transfer and reads its recipient back
from the saved record.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@thepastaclaw

thepastaclaw commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

♻️ No change to this PR's diff since commit 15d96ef (an empty commit, a merge of the base or a rebase onto it): that review stands — approved; @thepastaclaw review asks for a review of this commit (commit 3835f17)

QuantumExplorer and others added 6 commits November 24, 2026 08:05
…gain

ShieldedTipPending says the call sent nothing, not what became of the
earlier payment: the refusal ends when that payment executed as well as
when it can no longer execute. The docs no longer tell a host to review
and send again. A review's change is about confirmed recipients, not
paid tips.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…actly

From review:
- The READMEs and the send docs no longer say to review and send again
  after ShieldedTipPending: the refusal ends when the earlier payment
  executed as well as when it cannot, so a host resends only once that
  payment is known to have failed. Unconfirmed outcomes are named apart
  from "sent nothing".
- The JNI bridge reads tip strings as UTF-16 and decodes them strictly: a
  NUL beside a supplementary character is refused instead of rewritten by
  the lossy modified UTF-8 fallback, and a supplied memo that does not
  read is refused instead of sent as no memo.
- Kotlin's ShieldedTipRecipient copies its bytes in and out, so a send
  passes what the review returned.
- A review's change is about confirmed recipients, not paid tips.
- FfiSmokeTest calls the four tip natives through the loaded library.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
From review:
- The docs say to leave a pending tip's outcome unknown, and not resend,
  when the exact earlier attempt cannot be identified: the send returns
  no activity id, and look-alike entries can have other outcomes.
- Kotlin's ShieldedTipRecipient prints redacted, so logging a changed
  review does not tie the wallet to its previous recipient.
- The exact JNI string reader checks for null itself, at the raw call.
- The smoke test passes an emoji on its own: it must cross intact and be
  refused by Rust as an amount.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@QuantumExplorer QuantumExplorer added this to the v5.1.0 milestone Nov 24, 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.

Final validation — Phase 1 + Phase 2

Changes requested: 2 blockers

  • A contact tip can pay someone else after the contact's saved username changes hands — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactDetailView.swift:153-157 (new)
    Impact: A user tipping from a saved contact's detail screen can irreversibly send funds and an optional memo to the username's new owner instead of the selected contact.
  • Following the pending-tip recovery steps can pay the same tip twice — packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipFlow.swift:309-315 (new)
    Impact: A user who reopens an interrupted tip and follows the sheet's sync and review steps can pay the recipient again after the original tip succeeds.

This PR adds shielded tipping to SwiftExampleApp from a saved DashPay contact or a typed username, using the wallet SDK for review and sending. The Kotlin SDK emulator check passed; this head has no Swift CI result, and the reported Swift tests used stubs for the native tip symbols rather than exercising a funded iOS tip.

🔴 2 blocking | 🟡 3 suggestion(s)

Review provenance

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

  • Triage: normal by gpt-6.2-sol (effort low) — The SwiftExampleApp adds a substantial asynchronous review-and-send flow, but delegates payment execution, account selection, and duplicate-tip enforcement to the unchanged wallet API.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • 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-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactDetailView.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactDetailView.swift:153-157: A contact tip can pay someone else after the contact's saved username changes hands
  Impact: A user tipping from a saved contact's detail screen can irreversibly send funds and an optional memo to the username's new owner instead of the selected contact.
  The first tip from a saved contact's screen can go to a different identity without a recipient-change warning. The sheet drops `contactId` and passes only `dpnsHint`, which was saved when the contact was added as a display fallback. DPNS v3 permits both a transfer that rewrites `records.identity` and re-registration of a deleted, uncontested name. If the new owner has published a shielded address, the wallet reviews that owner and returns `.new` when there is no prior confirmation for the name. Send then checks that the recipient still matches the review, not that it matches the selected contact. Carry `contactId` into a wallet-owned contact review that refuses a mismatched resolution, retain the send-time recheck, and test a stale hint on the first tip. Keep the explicit username flow name-based.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipFlow.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipFlow.swift:309-315: Following the pending-tip recovery steps can pay the same tip twice
  Impact: A user who reopens an interrupted tip and follows the sheet's sync and review steps can pay the recipient again after the original tip succeeds.
  An interrupted tip can be paid twice even though the wallet correctly blocks another send while the first is unresolved. After relaunch, an unresolved review or a code 84 refusal offers Sync shielded now and Review again. Re-review keeps the entered amount and memo and enables Send tip when `unresolved` becomes false, the recovery sequence DP-35 explicitly expects. But the wallet clears the hold both when it sees the original payment execute and when it proves that payment cannot execute. Code 84 means only that this call sent nothing. Tell users to check the earlier payment's outcome, and don't present a cleared hold as permission to retry it. If the sheet offers a retry, gate it on the wallet reporting that the original payment failed, and test both settlement outcomes.
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipFlow.swift:159-166: Permanent balance-read failures look like a busy store and are retried indefinitely
  Impact: A user opening the profile or tip sheet when the shielded coordinator could not be configured sees a busy message or a stale balance instead of the setup error.
  The balance row hides an actionable error and retries every two seconds for as long as it remains mounted. `record(error:)` treats every `.walletOperation` as contention, but the native balance export uses that code for its 100 ms timeout and for non-contention failures such as an unknown wallet or a missing coordinator. Give the native timeout a distinct typed result, carry it through the SDK, and retain the last balance and retry only for that result. Show the original diagnostic for other failures and test both cases.
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipFlow.swift:108-117: A refused payment can be described as a previous tip in the next review
  Impact: A user reviewing again after an insufficient-funds refusal can see “Same recipient as the last tip” even though no tip was sent to that recipient.
  The copy implies a payment history the wallet does not establish. `send_resolved_shielded_tip` records the confirmed recipient before calling `shielded_transfer_to` (`tip_payment.rs:562–579`), so a later review can return `.unchanged` or `.changed` even if the previous attempt sent nothing. Describe the comparison as the last recipient confirmed for the name, not the last tip sent, and update the wording tests and QA expectations.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSheet.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSheet.swift:426-447: An older balance read can overwrite a newer result after a refresh
  Impact: A user whose balance read overlaps sync completion or account preparation can see a stale amount or an outdated Prepare button until the next refresh.
  The balance row can revert after displaying a newer result. Changing `.task(id:)` cancels the old view task, but `shieldedIdentityBalance` awaits a detached native operation that can still return, and `read()` applies both results and errors without checking cancellation or request order. The direct refresh after `prepare()` can also overlap the task-driven refresh. Route both paths through one refresh coordinator and let only the current, uncancelled request update the displayed identity's row or continue retrying.

QuantumExplorer and others added 12 commits November 24, 2026 08:45
…ther identity

A tip started from a saved contact passed only the contact's DPNS name.
If the name had since moved to another identity, the first review showed
the new owner as a new recipient with no warning.

review_shielded_tip and send_shielded_tip take an optional expected
identity (the contact's id) and refuse another one with
ShieldedTipRecipientMismatch, FFI code 85, mirrored in Swift and Kotlin.
The C exports take it as a nullable contact_identity_id. Nothing is
passed when the user typed the name.

Also documented: a pending tip's outcome is unknown when its exact
earlier attempt cannot be identified, and the unresolved check does not
count a transfer to an address the wallet never confirmed for the name.

Closes #6200

Co-Authored-By: Claude Fable 5.2 <[email protected]>
reviewShieldedTip and sendShieldedTip take an optional contactIdentityId
in Swift and Kotlin (defaulted, so existing callers compile), carried by
the JNI bridge to the C exports. Rust refuses a name that now belongs to
another identity; the wrappers do not compare ids.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ther identity

A tip started from a saved contact passed only the contact's DPNS name.
If the name had since moved to another identity, the first review showed
the new owner as a new recipient with no warning.

review_shielded_tip and send_shielded_tip take an optional expected
identity (the contact's id) and refuse another one with
ShieldedTipRecipientMismatch, FFI code 85, mirrored in Swift and Kotlin.
The C exports take it as a nullable contact_identity_id. Nothing is
passed when the user typed the name.

Also documented: a pending tip's outcome is unknown when its exact
earlier attempt cannot be identified, and the unresolved check does not
count a transfer to an address the wallet never confirmed for the name.

Closes #6200

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…let-shielded-tips

# Conflicts:
#	packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt
#	packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/errors/DashSdkErrorTest.kt
#	packages/rs-platform-wallet-ffi/ERROR_CODE_REGISTRY.md
#	packages/rs-platform-wallet-ffi/src/error.rs
#	packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift
#	packages/swift-sdk/SwiftTests/SwiftDashSDKTests/ErrorHandlingTests.swift
… claimed

From review:
- The transfer runs a check right after it reserves its notes, before
  anything is built or sent. A tip uses it to prove its source again:
  the wait for the store can be as long as a scan, and an identity can
  be removed meanwhile. A source that no longer stands releases the
  notes and nothing is sent.
- The first bind after a restart is refused without the account an
  unresolved note spend was paid from, and a bind that drops an account
  is refused while a damaged spend record is kept unloaded.
- A review and an identity balance hold the coordinator's operation
  admission for their local read, so a Clear cannot run between the
  binding check and the read.
- The recipients of saved transfers are read in one pass with the
  commitments their record id is checked against.
- The tip send keeps ErrorInvalidParameter (2) typed, as documented for
  a tip to the account it is paid from.

The tip result codes move to 85 (ShieldedTipPending) and 86
(ShieldedTipRecipientMismatch): v5.1-dev took 84 for the shielded Clear
refusal.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
v5.1-dev took 84 for the shielded Clear refusal, so ShieldedTipPending
is 85 and ShieldedTipRecipientMismatch is 86.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ttle balance reads

- After an earlier tip is reported pending, lock the inputs and offer
  only a shielded sync: the wallet stops refusing once the earlier
  payment resolves, whether or not it paid.
- Describe a review's change as the recipient last confirmed for the name.
- Keep the last balance with the wallet's message on a failed read, back
  off the retry, and apply only the latest read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…into feat/swift-example-shielded-tips

# Conflicts:
#	packages/kotlin-sdk/PARITY_SUMMARY.md
… refused

A tip from a saved contact passes the contact's identity to the review
and the send; the wallet refuses a name that now belongs to another
identity (shieldedTipRecipientMismatch), shown as not sent. Tip result
text follows the renumbered codes (pending is 85).

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

platform_wallet_manager_shielded_identity_balance reported a store held
by a scan as ErrorWalletOperation (6), the same code as an unknown wallet
or a missing coordinator, so a host told to "keep the last state and read
again" retried permanent failures too.

The timeout now returns ErrorShieldedBalanceBusy (87), mirrored in Swift
(shieldedBalanceBusy) and Kotlin (ShieldedBalanceBusy, retryable). It is
the only code of the read that means read again; every other code is a
failure to show.

Closes #6201

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ed through a real wallet

An instrumented test on an offline wallet passes distinct contact and
reviewed identities to sendShieldedTip and expects Rust's typed refusal,
which is reached before any lookup: it shows the id JNI read is the id
the wallet compared.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

@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

New on this head: This revision passes the selected contact’s identity to the wallet, removes the resend shortcut for unresolved tips, and describes recipient history as the last confirmation rather than the last payment. It also routes balance refreshes through one task and retries only when the wallet reports that the shielded store is busy. The Kotlin SDK emulator build and tests passed; the review check is pending, and the iOS tip flow has not been verified against the real native exports.

🟡 2 suggestion(s)

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

Review provenance

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

  • Triage: normal by gpt-6.2-sol (effort low) — The diff adds a substantial asynchronous SwiftUI payment flow, but leaves recipient validation, payer selection, duplicate-payment enforcement, and funds movement to the existing wallet APIs.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/TEST_PLAN.md:366: DP-37 expects the wrong error when a contact’s name changes hands after Review
  Impact: A tester who moves a contact’s name to another identity with a published shielded address between Review and Send can mistake the correct refusal for a regression.
  No funds are sent, but this sequence shows the generic “Not sent” outcome and the wallet’s recipient-changed message. The new contact wiring passes the saved identity and the reviewed recipient unchanged. Rust checks those two inputs against each other in `tip_payment.rs:519–522`, so that check still passes after the name moves. The subsequent fresh resolution differs from the reviewed recipient and returns `InvalidIdentityData` at lines 549–553, which the FFI maps to `walletOperation` (6), not the contact-specific code 86. The Swift test injects code 86 directly and verifies its presentation, not this sequence. Update DP-37 to expect `dashpay.tip.outcome.notSent` for a move after Review, and keep the code 86 expectation for a mismatch found during Review.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSheet.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSheet.swift:478-492: Prepare becomes tappable again before the balance reflects a successful preparation
  Impact: A user whose balance refresh is delayed by shielded sync can tap Prepare again and repeat a step that already succeeded.
  The row can still show an enabled Prepare button after the wallet has prepared the account. The new refresh path increments `prepares` to schedule a balance read, then immediately clears `preparing` on return. The button is disabled only while `preparing` is true, and a busy read preserves the old `.unverified` state that offers Prepare. Preparation is idempotent, but the SDK invokes the mnemonic resolver on every call. Keep Prepare disabled after success until the existing balance task applies a current, non-busy result.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • The tip sheet cannot recover a specific send result after startup sync settles it — If the app exits before showing a send result and startup sync confirms the payment before the user returns, the wallet retires the pending record. A fresh review does not identify that earlier attempt, so a user who missed the result can mistake a new tip for a retry.
    • Follow-up: Add a wallet-owned receipt that survives relaunch and exposes the settlement of the specific tip attempt, without matching payments by recipient or amount.

QuantumExplorer and others added 2 commits November 24, 2026 09:30
…ands

After a successful prepare, Prepare stays off until a read started after
it applies a result that is not busy. DP-37 states the moved contact name
is refused with code 86 at review and at send.

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

@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

New on this head: This update keeps Prepare hidden in the Swift shielded-tip balance row until a fresh, non-busy read applies, and updates DP-37 to expect the wallet’s contact-mismatch code at both Review and Send. The Kotlin SDK emulator build and tests and policy reconciliation passed; the review check is pending. The reported iOS simulator tests used native stubs, so linkage against the real wallet and the device flows remain unverified.

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

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

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: A busy refresh tells users to prepare an account they just prepared
Impact: After Prepare succeeds, a user whose balance refresh hits a busy store is told to prepare again even though the Prepare button is hidden.
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipFlow.swift:257-259

The row gives the user an instruction they can’t follow after a successful Prepare. The new awaitingReadAfterPrepare gate hides the button, but a busy read preserves the previous .unverified state, so the row still says “prepare it to read the balance.” While that flag is set, replace the stale instruction with a refresh message without implying the balance is known. The next non-busy result can then determine what the row shows; update DP-38 to expect that interim message.

        case .balance(.unverified):
            if awaitingReadAfterPrepare {
                return "Preparation complete. Refreshing the shielded balance…"
            }
            return "Not verified yet. The wallet proves this identity's shielded account with "
                + "its seed once per session; prepare it to read the balance."

source: gpt-6.2-sol (phase2-reviewer: general, architecture-layering, security-auditor)

Review provenance

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

  • Triage: normal by gpt-6.2-sol (effort low) — ShieldedTipFlow.swift adds an intricate asynchronous payment UI, but the diff changes how the app invokes and presents existing wallet operations, not how the wallet selects funds or executes transfers.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • New since the last final review (9e3b3d7c): 1 suggestion(s) on unchanged code listed as follow-up candidates
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

QuantumExplorer and others added 10 commits November 24, 2026 10:04
…ance read waits

From a local code review:
- A tip review and an identity balance read took the coordinator's
  operation admission and kept it while they waited for the store, which
  a scan can hold for minutes: a Clear requested meanwhile was refused.
  They now wait without it and check after the read that no Clear is in
  progress and the binding (or the preparation) still stands.
- The busy outcome of the balance read is the wallet's: the bounded read
  shielded_identity_balance_now returns ShieldedBalanceBusy after
  SHIELDED_IDENTITY_BALANCE_WAIT, and the C export only maps it.
- A bind does not purge a dropped account that a spend saved a record
  for after the bind's check: the record stays, and what reads it fails
  closed until the account is bound again.
- A tip from an account that is not bound, or whose key the seed does
  not derive, is refused before its recipient is recorded as confirmed.
- A review reads the bound keys after its lookups.
- Items used only by shielded code are gated on the feature, so the
  default-feature build has no dead code.
- Test randomness is seeded; the wrong-seed assertion runs against an
  intact record; the registry rows state the Kotlin mirrors.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…let-shielded-tips

# Conflicts:
#	packages/rs-platform-wallet/src/wallet/platform_wallet.rs
…ts note list

From review:
- The store loader treats a note-spend transition with no nullifier
  listed as a damaged note-spend row: it is retained without being
  loaded, so it is not listed as an identity-funded debit and tips fail
  closed on it.
- ShieldedBalanceBusy (87) is described as what it is: the bounded read
  did not finish in time because the wallet's state or its shielded
  store was held. It no longer says a scan or a spend holds the store,
  which the timeout does not establish.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…test on an unbound wallet

The busy code of the identity balance read means the read did not finish
within its wait budget, because the wallet's state or its shielded store
was held. The Swift and Kotlin docs named a scan or a spend only.

ShieldedTipFfiTest leaves the wallet unbound, so a contact id dropped on
the way stops at the binding check instead of reaching a name lookup, and
it expects exactly NotFound for an identity the wallet does not hold.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ail closed on an undecodable spend

A balance read that overlaps an admitted Clear returned Unverified, also
when that Clear gave up without wiping anything and the identity's proof
still stood. It now returns ShieldedBalanceBusy, and Unverified only once
the proof no longer stands.

Asking whether a Clear is admitted took a shared permit of the operation
admission for an instant, which could refuse a Clear requested in that
instant. The coordinator now keeps a flag for it.

Also:
- a saved spend that lists no notes and does not decode blocks tips
  instead of reading as an identity-funded shield;
- a tip review on a wallet removed during its lookups is refused instead
  of reading the purged recipients as none;
- a re-keyed account is purged as before when a spend saved its record
  during the registration: only a dropped account keeps its state;
- a tip derives its spend keys once;
- the README shows the review's third argument, lists FFI code 20 beside
  18, and says a Clear ends an identity's proof.

Tests: the balance read during and after a Clear, a numbered slot an
identity holds at the claim, the u64 fraction boundary of the amount.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… and during a Clear

The Swift and Kotlin guides still said the read waits at most 100 ms for
the shielded store. The budget covers the whole local read. The busy
error is also what the read returns while a shielded Clear is running.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Base automatically changed from feat/sdk-shielded-tip-wrappers to v5.1-dev November 24, 2026 04:10
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. 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 the waiting-bots Waiting for the review bots to report on this head label Nov 24, 2026
…e-shielded-tips

# Conflicts:
#	packages/rs-platform-wallet/src/wallet/shielded/tip_payment.rs
#	packages/rs-platform-wallet/src/wallet/shielded/tip_payment_tests.rs
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. 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.

@QuantumExplorer
QuantumExplorer merged commit 686c76d into v5.1-dev Nov 24, 2026
25 of 27 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/swift-example-shielded-tips branch November 24, 2026 04:14
@github-actions github-actions Bot removed the waiting-bots Waiting for the review bots to report on this head label Nov 24, 2026
QuantumExplorer added a commit that referenced this pull request Nov 24, 2026
…ftExampleApp

The Kotlin tip rows DP-33 to DP-38 now mirror Swift DP-33 to DP-38 (#6198)
id for id; DP-39 (rotation or tab switch while sending) is Kotlin only.
Test tags use Swift's accessibility ids where the flow is the same
(dashpay.tip.contactEntry, .review.error, .recipient.identity, .sync,
.busy, .balance, .outcome.submitted, .done and the rest).

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.

2 participants