Skip to content

fix(platform-wallet)!: name private entry and contact request payments in shielded activity - #6226

Merged
QuantumExplorer merged 3 commits into
v5.1-devfrom
fix/platform-wallet-private-entry-shielded-activity
Nov 24, 2026
Merged

QuantumExplorer merged 3 commits into
v5.1-devfrom
fix/platform-wallet-private-entry-shielded-activity

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

When a wallet pays for a private document entry from its shielded balance, the only thing that leaves the balance is the fee. A DashPay private contact request, and the private reply that accepts one, are paid the same way.

Until now the device that made the payment listed it in Shielded Activity as an unnamed "Shielded Spend" of 0 DASH. On iOS the detail also said the entry was "reconstructed from on-chain note data", which is the text meant for wallets restored from a seed.

With this change the wallet records what the payment was for, and both apps show it by name with the fee as its amount.

SwiftExampleApp, row and detail

Before After
Row Shielded Spend · -0 DASH Private Contact Request · -0.001530744 DASH
Detail: Type Shielded Spend Private Contact Request
Detail: Amount -0 DASH -0.001530744 DASH
Detail: Fee 0.001530744 DASH 0.001530744 DASH
Detail: extra footnote "Restored wallets can't always recover the operation type. This entry was reconstructed from on-chain note data." section Recipient Identity with the id, and "The amount is the fee, which is all that left the shielded pool."

A private document entry reads Private Document Entry, with a Data Contract section in place of Recipient Identity.

KotlinExampleApp, row

Before After
Headline Shielded Spend Private Contact Request (or Private Document Entry)
Supporting line Confirmed Confirmed. The amount is the fee, which is all that left the shielded pool.
Amount −0.0000 DASH −0.0015 DASH

A row that failed keeps its attempted fee as the amount, as every failed row keeps its amount, and says "It did not go through; the fee shown was not charged."

Issue being fixed or feature implemented

Found on 2026-11-24 by the QA passes of SwiftExampleApp and KotlinExampleApp at v5.1.0-dev.4 on a protocol version 15 devnet: the private entry and the private contact requests the app had just sent appeared as "Shielded Spend, −0 DASH".

The cause is not the one the report gave. The report said the wallet records no live activity entry for this spend, so the app falls back to reconstruction. The wallet did record one (private_document_create_from_pool_with_metadata called record_pending_activity, and the log line reads live activity entry recorded (pending) kind=ShieldedSpend). It recorded it under the residual kind ShieldedSpend with amount: 0, because no kind existed for this transition. The "reconstructed" text is a footnote SwiftExampleApp shows for every row of that kind, live or restored. The right fee in the Swift detail came from that live row.

What was done?

Rust wallet (rs-platform-wallet), where the decision lives

  • ShieldedActivityKind gains two kinds:
    • PrivateDocumentCreate (stored tag 13): an entry appended to a private document type's store. Counterparty: the 32-byte data contract id.
    • PrivateContactRequest (stored tag 14): a DashPay private contact request, or the private request sent back to accept one. Counterparty: the 32-byte id of the identity the request is to.
  • record_pending_private_document_create records the row for a built type 29 transition: direction Out, fee set, and amount equal to the fee. Nothing but the fee leaves the pool, so the fee is what a host that prints a row's amount should print. This one decision serves both apps.
  • The payment takes one PrivateDocumentPurpose (Entry, or ContactRequest { sender, recipient, account_reference }). The activity row's counterparty and the journaled payment's recipient are both read from it, so they cannot name different identities. pay_private_contact_request builds the contact request purpose; create_private_document_entry passes Entry.
  • ShieldedActivityKind::from_tag is the inverse of tag() and lives beside it. The tests hold both to a literal table of every stored tag and its kind, and check all 256 possible tag values, so two kinds that swapped tags, or a decoder arm with no row in the table, fail.

FFI (rs-platform-wallet-ffi)

  • The restore path calls the wallet's from_tag instead of keeping its own tag table, so tags 13 and 14 come back as their kinds when the host hands its rows back at boot. Without this a restart would load them as the residual kind, and the next status change would store that over the named row.
  • Field docs of ShieldedActivityFFI updated. No field added, removed or retyped.

Apps (display only)

  • SwiftExampleApp: labels, icons and the detail section for tags 13 and 14; the Storage Explorer names both tags. The restored-wallet footnote stays on tag 7 only.
  • KotlinExampleApp: labels and the supporting line for tags 13 and 14.
  • Both TEST_PLANs: SH-02 now says what these rows read; DOC-19 and the private contact request rows point to it.

Left as it was

Public interface changes

Stored activity kind tag (ShieldedActivityKind::tag, FFI kind_tag, Swift PersistentShieldedActivity.kindTag, Kotlin ShieldedActivityEntity.kindTag)

  • Two values appended: 13 and 14. Tags 0 to 12 keep their meaning, and a unit test pins every tag.
  • The column types do not change (u8 over the FFI, Int in SwiftData and Room), so there is no SwiftData schema version and no Room schema bump. Room stays at version 21, the version of the base (set by feat: set, change and remove DashPay profile payment addresses in KotlinExampleApp #6146).
  • Going back to an older build: a build that does not know a tag shows the row as "Shielded Spend" (the apps' label functions and Rust's decoder fall back to the residual kind), so the row still loads. But when that older build next emits the row, on a status change, it sends tag 7 and the host stores 7 over the original tag. After that the kind is lost for good: a later build does not recover it, as the scan cannot. The amount and fee are not affected.

Meaning of amount for the two new kinds

  • For tags 13 and 14 amount is the fee, the same number as fee. It is not a second charge, and nothing adds the two fields together (checked in the wallet, both SDKs and both apps).
  • Before, the same spend was stored with amount = 0 under tag 7.
  • For every other kind amount is unchanged.

Meaning of counterparty for the two new kinds

  • Tag 13: the 32-byte data contract id. Tag 14: the 32-byte id of the recipient identity. Before, this spend stored no counterparty.
  • A row of kind 14 stands for an attempt. It is written before the payment is broadcast, as every spend's row is. For a request that goes through, the recipient is also kept in the outgoing request row. For one that is refused, the activity row stays, as Failed, with the recipient's id, although no contact request to that identity was sent or stored. A host that audits what its wallet store retains should count this field.

Rust API

  • platform_wallet::wallet::shielded::ShieldedActivityKind has two new variants. The enum is not non_exhaustive, so Rust code outside this repository that matches it exhaustively needs two more arms. Inside the repository every match already has a fallback arm.
  • With the serde feature the enum uses its derived codec, not the numeric tag: a Rust host built before this change does not deserialize an activity entry of either new kind, and a batch decoded as a whole fails with it. Such a host has to be updated before it reads data written by this build.
  • New public function ShieldedActivityKind::from_tag(tag, identity_id, has_identity).
  • No other public function signature changes: the function that changed its parameters is pub(in crate::wallet).

Not changed: FFI struct layouts, exported C symbols, JNI signatures, Swift and Kotlin SDK method signatures.

How Has This Been Tested?

Run locally on macOS, targeted checks only:

  • cargo fmt --all -- --check
  • cargo test -p platform-wallet --all-features --lib -- wallet::shielded wallet::platform_wallet private_contact (run on the second commit): 690 tests. 689 passed in the full filtered run; balance_emitter_tests::should_emit_once_a_failed_scan_releases_the_store, a deadline-based test this change does not touch, missed its deadline once while another build was running on the machine and passed when rerun. The third commit changes only the activity kind tests in Rust; -- wallet::shielded::activity was rerun on it: 24 passed. New tests:
    • wallet::shielded::coordinator::tests::should_record_a_private_document_create_under_its_own_kind_with_its_fee: builds a real type 29 transition with the DPP builder and a proof, records it for both purposes, and checks kind, direction, amount equal to the fee, fee, counterparty, the row's key (the change note) and its spent nullifier. Then it runs the scan derivation and checks the same row is confirmed with its kind kept and no reconstructed "Shielded Spend" row is added beside it.
    • wallet::shielded::operations::tests::should_name_one_recipient_for_a_contact_request_s_row_and_its_journal_record.
    • wallet::shielded::activity::tests: should_write_the_stored_tag_of_every_kind, should_read_every_stored_tag_as_the_kind_it_was_written_for, should_read_a_token_unshield_without_an_identity_as_recipient_unknown.
  • cargo test -p platform-wallet-ffi --all-features --lib -- activity shielded (second commit; the FFI crate is unchanged since): 129 passed.
  • cargo clippy -p platform-wallet -p platform-wallet-ffi --all-targets --all-features --locked -- --no-deps -D warnings: clean (platform-wallet rerun on the third commit).
  • Kotlin (Homebrew openjdk@17): ./gradlew :app:testDebugUnitTest --tests '*ShieldedActivityKindsTest': 3 tests, 0 failures, with the formatting locale pinned.
  • python3 scripts/check_sdk_parity_manifest.py: OK.
  • CI on the first two commits: "Swift SDK build + tests (warnings as errors)" (first commit), "Rust workspace tests" (first commit) and the Kotlin emulator job (both) passed. The Kotlin job's first run on the first commit failed on MasternodeVotingKeySigningTest with "User not authenticated", which this change does not touch, and passed when rerun.

Not yet verified

  • Swift was not compiled locally; the CI Swift job is what compiles it and runs ShieldedActivityKindDisplayTests. The third commit changes one Swift string and its test, parsed locally only.
  • No simulator or emulator run: the named rows have not been seen on a device against a protocol version 15 network.

Breaking Changes

For Rust consumers of platform-wallet outside this repository only:

  • ShieldedActivityKind has two new variants; an exhaustive match needs two more arms.
  • With the serde feature, a build that predates the variants does not read an activity entry of either new kind.

Nothing breaks for the apps or over the FFI: no struct layout, symbol, JNI signature or stored schema changes.

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

PR Hygiene · 026d32d

  • Bots — thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Reviewer requests paused — your 5 review slots are occupied; this PR is excluded from reviewers' queues. Required approvals still count without a slot.
  • Build green
  • Approvals
    • kotlin-sdk (packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedActivityScreen.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/shielded/ShieldedActivityKindsTest.kt and 1 more) — HashEngineering
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/src/persistence.rs, packages/rs-platform-wallet-ffi/src/shielded_persistence.rs) — HashEngineering or ZocoLini or llbartekll or romchornyi
    • rs-platform-wallet (packages/rs-platform-wallet/src/wallet/platform_wallet.rs, packages/rs-platform-wallet/src/wallet/shielded/activity.rs, packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs and 1 more) — HashEngineering or ZocoLini or llbartekll or romchornyi
    • swift-sdk (packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentShieldedActivity.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift and 2 more) — llbartekll or romchornyi

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.

… in shielded activity

A private document entry paid from the shielded pool (type 29), which is
also how DashPay private contact requests and private replies are paid,
was recorded live as the residual kind ShieldedSpend with amount 0. Both
example apps therefore showed the device's own payment as "Shielded
Spend, -0 DASH", and SwiftExampleApp added the restored-wallet footnote
it shows for every row of that kind.

The wallet now records two kinds, appended to the stored tags:
13 PrivateDocumentCreate (counterparty: the data contract id) and
14 PrivateContactRequest (counterparty: the recipient identity id).
Nothing but the fee leaves the pool, so the row's amount is the fee.
The FFI restores both tags at boot instead of folding them into the
residual kind. The apps label the two kinds and say the amount is the
fee. No FFI struct, JNI signature or stored schema changes.

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

Files selected for processing: 15

  • packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedActivityScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/shielded/ShieldedActivityKindsTest.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/ShieldedActivityEntity.kt
  • packages/rs-platform-wallet-ffi/src/persistence.rs
  • packages/rs-platform-wallet-ffi/src/shielded_persistence.rs
  • packages/rs-platform-wallet/src/wallet/platform_wallet.rs
  • packages/rs-platform-wallet/src/wallet/shielded/activity.rs
  • packages/rs-platform-wallet/src/wallet/shielded/coordinator.rs
  • packages/rs-platform-wallet/src/wallet/shielded/operations.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentShieldedActivity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageRecordDetailViews.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ShieldedActivityKindDisplayTests.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

@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.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 24, 2026
@thepastaclaw

thepastaclaw commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 026d32d) · triage: normal

@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: 1 blocker

  • A private payment can show a confirmed fee after another spend consumed its notes — packages/rs-platform-wallet/src/wallet/shielded/operations.rs:3096-3101 (new)
    Impact: A user spending from the same wallet on two devices can see a lasting debit for a private entry or contact request that never executed if the losing device accepts a spent-input snapshot before scanning the winning spend.

The wallet now gives private document entries and DashPay requests and replies their own shielded activity kinds, records the intended fee as the amount, and carries the new tags through FFI and both example apps without a schema change. Rust workspace tests, the Kotlin emulator build and tests, and the Swift frozen-schema check passed; the Swift build and tests are pending.

🔴 1 blocking | 🟡 7 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Failed private payments still display an amount that looks like a debit
Impact: Someone viewing a failed private payment sees a negative amount in both example apps, and an ordinary Fee field in Swift, even when the attempt cost nothing.
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift:470-475

A payment refused before delivery still looks like a charge at a glance. Rust records the intended fee before broadcast and preserves it on the Failed row. Swift renders it under the usual Amount and Fee labels, and Kotlin retains the signed debit next to the failure message. Keep the intended fee in history, but label it as attempted or omit the debit for failed rows.

source: gpt-6.2-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 12: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The change spans Rust wallet bookkeeping, persisted activity tags, FFI restoration, and two app displays, but it does not change how funds move or require a storage migration.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (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 — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (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/rs-platform-wallet/src/wallet/shielded/operations.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:3096-3101: A private payment can show a confirmed fee after another spend consumed its notes
  Impact: A user spending from the same wallet on two devices can see a lasting debit for a private entry or contact request that never executed if the losing device accepts a spent-input snapshot before scanning the winning spend.
  The new row can attribute a specific fee to a contract or recipient even though that operation never executed. When a type 29 payment uses two or more real notes, its bundle has no dummy spend nullifier to distinguish it from a competing spend of the same notes. The honest DAPI wait checks the requested transaction's result, but the SDK cannot authenticate that check from the returned proof: it accepts a snapshot proving only that the requested nullifiers are spent. If an endpoint returns that snapshot before the scan sees the competing spend, `settle_affected_state_spend` confirms the row and marks the notes spent. `mark_spent` then drops the saved transition the scan needs to distinguish the two spends, and the scan's conflict handler only fails pending rows. #6180 tracks the existing status problem; this PR turns that status into a nonzero debit for a named payment and tells users the fee left the pool. Mark the notes spent without confirming the debit from an ambiguous snapshot, and retain enough evidence for sync to resolve the payment without keeping it eligible for rebroadcast. Cover the snapshot-before-scan ordering in a wallet regression test.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:2942-2943: The payment API lets activity and recovery name different recipients
  Impact: If a future call site supplies inconsistent recipient metadata, Shielded Activity can name the wrong identity or show a generic document entry while recovery tracks the actual contact.
  `contact_recipient` controls the activity row, while the optional `private_contact` record independently carries the recipient used for recovery. The current DashPay caller derives both from the same identity, but the signature accepts conflicting values. The new coordinator test supplies the expected recipient directly and would still pass if the production reply path forwarded the wrong identity or none at all. Pass one typed payment purpose that carries the recipient once and makes only the journal-specific metadata optional. Add an offline test through the wallet's private accept path asserting that the row names the original requester.

In `packages/rs-platform-wallet-ffi/src/shielded_persistence.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/shielded_persistence.rs:133-136: A failed private request can leave a saved recipient ID even when nothing was sent
  Impact: SDK hosts auditing what their wallet store retains can overlook recipient IDs for attempts that never produced an outgoing contact request.
  Shielded Activity now retains the intended recipient independently of the outgoing request. The recorder queues tag 14 and its recipient before broadcast. When submission is refused before delivery and the saved transition is retired, `settle_private_document_payment` discharges the journal but keeps the activity row as Failed; the request flow returns before readback can save an outgoing request. Document that tag 14 covers attempts, including failed ones, and correct the PR description's claim that the recipient is already stored in every case.

In `packages/rs-platform-wallet/src/wallet/shielded/activity.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/activity.rs:145-157: Older Rust Serde readers reject activity records with the new kinds
  Impact: A Rust host using the optional Serde API cannot read an activity record containing either new kind after downgrading to a build that predates the variants.
  A record with either new variant fails to deserialize on older Rust builds, and it can make an entire batch unreadable if the host decodes the batch at once. `ShieldedActivityEntry.kind` uses the enum's derived Serde codec, including in `ShieldedChangeSet`; it does not use the FFI numeric tag decoder that falls back to `ShieldedSpend`. Document this distinction and the exhaustive-match source break in the 5.1 upgrade and release notes so Rust hosts can update their readers before writing the new variants.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/ShieldedActivityEntity.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/ShieldedActivityEntity.kt:34-35: An older build can overwrite the payment label when it updates a restored row
  Impact: A user who reopens the same store with a pre-tag SDK and lets it confirm a pending private payment can still see only Shielded Spend after upgrading again.
  The original classification can be lost on rollback, not just hidden while the older build is running. The older FFI decoder loads tags 13 and 14 as `ShieldedSpend`; when a scan confirms the row, the wallet re-emits the same entry ID as tag 7 and both hosts upsert it over the original tag. The scan cannot recover the classification. This does not change the amount or stop the older build from opening the store, but the Room comment saying the unknown tag is kept needs to be qualified. Carry the caveat already in the PR description into the public persistence and release notes.

In `packages/rs-platform-wallet-ffi/src/persistence.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/persistence.rs:8204-8206: A new activity kind can silently become Shielded Spend if the restore table misses it
  Impact: If a future wallet kind gets an emitted tag but no matching FFI restore arm, a mobile host can overwrite its saved classification on the next status update.
  Tags 13 and 14 round-trip on this head, but adding a future variant to `ShieldedActivityKind::tag()` does not force a corresponding FFI decoder update. The decoder's wildcard returns a valid but different kind, which a later status upsert saves as tag 7. Keep the stable tag mapping and its inverse together in the wallet crate, test round trips for all assigned tags there, and let FFI pass the raw fields to that decoder.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift:470-475: Failed private payments still display an amount that looks like a debit
  Impact: Someone viewing a failed private payment sees a negative amount in both example apps, and an ordinary Fee field in Swift, even when the attempt cost nothing.
  A payment refused before delivery still looks like a charge at a glance. Rust records the intended fee before broadcast and preserves it on the Failed row. Swift renders it under the usual Amount and Fee labels, and Kotlin retains the signed debit next to the failure message. Keep the intended fee in history, but label it as attempted or omit the debit for failed rows.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/shielded/ShieldedActivityKindsTest.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/shielded/ShieldedActivityKindsTest.kt:25-32: The Kotlin amount test fails under a decimal-comma locale
  Impact: Contributors running the test with a French or German default formatting locale get a failure even though the amount is formatted correctly for that locale.
  The assertion expects `−0.0015 DASH`, but `signedAmount` calls `String.format` without a locale, so those JVMs produce `−0,0015 DASH`. Make the test's formatting locale explicit and restore it afterward, or derive the expected display from the active locale without changing production formatting.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
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 Nov 24, 2026
…and journal record

Review follow-ups for the private entry and contact request activity
kinds:

- The payment takes one PrivateDocumentPurpose instead of a recipient
  for the activity row and a separate journaled payment, so the two
  cannot name different recipients.
- ShieldedActivityKind::from_tag is the inverse of tag() and lives beside
  it; the FFI restore path calls it instead of keeping its own table. A
  test lists every kind through a match with no wildcard arm and reads
  each back from its tag.
- Docs say that a kind 14 row stands for an attempt (a refused payment
  keeps its row and recipient id), and what a build that predates a tag
  does with it, by numeric tag and by serde.
- The Kotlin amount test pins its formatting locale.

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

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@QuantumExplorer QuantumExplorer changed the title fix(platform-wallet): name private entry and contact request payments in shielded activity fix(platform-wallet)!: name private entry and contact request payments in shielded activity Nov 24, 2026
@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 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 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.

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

Changes requested: 1 blocker

  • A private payment can show a confirmed fee after another spend consumed its notes — packages/rs-platform-wallet/src/wallet/shielded/operations.rs:3148-3153 (thread, carried)
    Impact: A DashPay user spending from a wallet shared by two devices can see a lasting confirmed debit for a specific recipient even though the request never landed and the send API reports it as pending.

New on this head: This revision moves stored activity-tag decoding into the Rust wallet and derives each private payment’s activity row and recovery journal from the same payment purpose. It also documents downgrade and failed-attempt behavior and pins the Kotlin amount test’s locale. The Kotlin emulator and Swift frozen-schema checks passed; Rust workspace tests were pending, with no failed code checks reported.

🔴 1 blocking | 🟡 3 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Failed private payments still display an amount that looks like a debit
Impact: Example-app users inspecting a failed private entry or contact request see a negative DASH amount even though the failure message says nothing left the shielded pool.
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift:470-475

A failed attempt looks like a debit. Swift shows the signed amount in both the list and detail, and the detail also labels the retained fee as Fee; none of those fields checks status. Kotlin likewise renders signedAmount(row) alongside its failure message. Keep the stored attempt values, but omit the signed debit for failed fee-only rows or label the value as an attempted fee that was not charged.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality)

Still open from earlier rounds (1)

  • 🔴 Blocking: A private payment can show a confirmed fee after another spend consumed its notes — packages/rs-platform-wallet/src/wallet/shielded/operations.rs:3148-3153 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The diff changes wallet activity classification, fee display, and persisted tag handling across Rust and both mobile apps, but it does not change funds movement, coin selection, consensus, or storage migration logic.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (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/Core/Views/ShieldedActivityView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/ShieldedActivityView.swift:470-475: Failed private payments still display an amount that looks like a debit
  Impact: Example-app users inspecting a failed private entry or contact request see a negative DASH amount even though the failure message says nothing left the shielded pool.
  A failed attempt looks like a debit. Swift shows the signed amount in both the list and detail, and the detail also labels the retained fee as `Fee`; none of those fields checks status. Kotlin likewise renders `signedAmount(row)` alongside its failure message. Keep the stored attempt values, but omit the signed debit for failed fee-only rows or label the value as an attempted fee that was not charged.

In `packages/rs-platform-wallet/src/wallet/shielded/activity.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/activity.rs:1344-1367: The codec tests can miss a missing or renumbered activity tag
  Impact: A future wallet build can pass these tests while restoring a user’s saved activity as the wrong operation.
  The replacement tests can miss a compatibility regression. The round-trip test decodes the byte produced by `tag()`, and the distinctness test only counts unique values, so swapping tags 10 and 11 in both mappings would pass while older token purchases and transfers would restore as each other. The decoder move also removes the FFI assertion that pinned tag 11, and the separate wallet test pins only tags 12–14. For new kinds, adding an arm to the no-op exhaustive match is enough to compile even if the fixture list and decoder both omit the new kind. Use literal `(stored_tag, kind)` fixtures to test both directions, and either generate the fixture list and exhaustive check together or describe the match as a reminder rather than a guarantee.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/shielded/ShieldedActivityKindsTest.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/shielded/ShieldedActivityKindsTest.kt:24-33: The Kotlin amount test overwrites JVM locale overrides after it finishes
  Impact: Contributors running JVM tests with separate formatting or display locales can get order-dependent results from later locale-sensitive tests.
  Later tests can inherit a different locale from the one the JVM started with. `Locale.getDefault()` captures only the general default, while `Locale.setDefault(Locale)` overwrites the `FORMAT` and `DISPLAY` defaults as well. For example, a worker with a French formatting locale and an English general locale ends this test with English formatting. Save and set only `Locale.Category.FORMAT`, which is what the amount formatter reads.

In `packages/rs-platform-wallet/src/wallet/shielded/operations.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/operations.rs:3148-3153: A private payment can show a confirmed fee after another spend consumed its notes
  (carried; thread: https://github.com/dashpay/platform/pull/6226#discussion_r4681421586)

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix.
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 Nov 24, 2026
…tures

Second round of review follow-ups:

- The activity kind tests now check a literal (stored tag, kind) table in
  both directions, and every one of the 256 possible tags: two kinds that
  swapped tags, or a decoder arm with no row in the table, fail.
- The Kotlin amount test saves and restores only the FORMAT locale.
- A failed private entry or contact request row says the fee shown was
  not charged, in both apps.
- PrivateContactRequest docs: Confirmed says the payment's notes read
  spent, not that the request was read back.

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

Copy link
Copy Markdown
Member Author

On the review finding that has no inline thread, "Failed private payments still display an amount that looks like a debit":

Partly taken in 026d32d. The failed note for these two kinds now reads "It did not go through; the fee shown was not charged." in both apps, which is the second option the finding offers.

Not taken: hiding the signed amount for failed rows of these two kinds. Every kind's failed row shows its attempted amount with its sign beside the Failed badge (a failed send shows its amount the same way), so special-casing two kinds would make the list inconsistent and put a per-kind decision in the apps. Changing how every failed row shows its amount is outside this PR.

@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.

@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 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.

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

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

New on this head: This revision pins every assigned shielded activity tag in both codec directions, scopes the Kotlin test’s locale override to formatting, and clarifies in both apps that a failed payment’s displayed fee was not charged. The Kotlin SDK emulator check passed on this head; no failed code checks or final-head Rust or Swift build and test results were listed.

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

Disputed — left to maintainers (1)

  • 🔴 Blocking: A private payment can show a confirmed fee after another spend consumed its notes — packages/rs-platform-wallet/src/wallet/shielded/operations.rs:3096-3101 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The change spans Rust wallet bookkeeping, persistence bindings, and two mobile UIs, but changes how existing payments are recorded and displayed rather than changing funds movement, coin selection, consensus, or storage schemas.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (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 — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

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

@github-actions

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 Nov 24, 2026
@QuantumExplorer
QuantumExplorer merged commit a060049 into v5.1-dev Nov 24, 2026
33 of 34 checks passed
@QuantumExplorer
QuantumExplorer deleted the fix/platform-wallet-private-entry-shielded-activity branch November 24, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants