Registry Mirror
Skip to content

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

DashPay users have no way to receive private payments by username. This PR lets an identity publish a reusable shielded (Orchard) tip address on its DashPay profile and lets a wallet pay a username's tip address. Each wallet identity's tips land in a dedicated ZIP-32 account, so tip viewing keys stay separate from ordinary wallet activity. An externally generated Orchard address can be published instead.

The contract field shipped in #4768 and the DPNS resolver fix in #4769. This follows #4380 and dashpay/dips#188.

This is the first PR in a three-part stack:

  1. This PR: wallet, storage, and C/JNI/Swift/Kotlin SDK bindings.
  2. feat(platform-wallet): own the shielded-tip payment decisions in the wallet #5709: durable tip recovery, retry disposition, and recipient-confirmation history in Rust.
  3. feat: shielded-tip screens over the wallet's tip decisions #5711: Swift and Kotlin tip screens using those wallet APIs.

Built on #5934

This PR is merged with #5934, which puts the shielded lifecycle boundary in one place, and carries #5905's per-identity account. It lands after #5934; until then its diff also shows #5934's changes.

  • Wallet operations take the manager's coordinator, so the bind, add-account, preparation and tip-send paths drop their coordinator arguments. Tests configure it with manager.configure_shielded(..).
  • This PR's per-entry guards go away: the coordinator ownership check, clear-generation sampling, and the Clear gates on preparation, publication and send. Each shielded mutation holds coordinator.admit() for as long as it persists and installs, taken after any shield_guard.
  • Swift and Kotlin no longer delete shielded rows after Clear; the persister's wipe_shielded_state callback does it before Clear returns.
  • The Clear race tests run against the shared admission instead of the removed guards.

What was done?

  • Dedicated accounts. An identity shielded account at derivation index i uses account 0x40000000 + i. prepare_shielded_identity_address proves with the seed that the identity holds that slot, binds the account and flushes persistence before returning the address. The wallet-generation gate and the coordinator admission keep bind, flush, and prepared-account bookkeeping ahead of removal or Clear; a retained handle is refused after same-ID recreation. Identity discovery rebuilds tip accounts without the profile, and retired accounts keep scanning.
  • Publishing. PlatformWallet::write_dashpay_profile carries the core, platform and shielded payment addresses as explicit keep/set/remove updates, so unrelated profile edits keep them, and checks that the connected chain's contract has the field. It refuses this wallet's ordinary-account addresses, including diversified addresses. An external receiving address of this wallet's identity shielded account must have been prepared in this session for the identity at the slot it holds now. Internal-scope identity addresses are refused because the wallet scans external receiving addresses; external-wallet addresses remain allowed. Clear invalidates preparation, including a Clear racing the final preparation step. Publication takes the current wallet generation’s payment gate before the placement lock and holds it through signing, broadcast, and cache/persistence completion; removal waits, and removed or replaced handles are refused before validation.
  • Placement lock. A per-wallet identity_placement lock orders identity moves against the tip operations that depend on the moving identity's slot. Discovery, loading, changeset apply and public state write guards take it to move an identity. Public manager handles expose read access only. Mutable state guards, changeset apply, identity loading, discovery, and own/contact profile synchronization check the handle's generation under the wallet-manager write lock, so a retained handle cannot mutate a same-ID replacement under an old placement lock. Preparation and publication hold it through their operation. Tip sends release it during recipient resolution, then revalidate the source and hold it through spending.
  • Paying a username. resolve_shielded_tip returns the verified identity and address for the user to confirm. send_shielded_tip re-resolves, refuses if either changed, and takes a ShieldedTipSource. Identity(id) pays from that identity's tip account after the seed proves the slot it holds. Account(n) pays from an ordinary account, or from the tip account of an empty (retired) slot. The generation payment gate fences proving, bookkeeping, and broadcast against removal, and a stale generation is refused after same-ID recreation. The coordinator admission also excludes Clear through proving, persistence, broadcast, and result settlement. The source has the same shape in C (ShieldedTipSourceFFI), JNI, Swift (ShieldedTipSource) and Kotlin.
  • Profile authority. Rust emits profile updates through the existing dashpay_profiles overlay: a missing key is unknown, a profile is present, and an explicit None is confirmed absent. The first confirmed absence emits an update even on a cold cache. A size-negotiated callback carries these updates to Swift and Kotlin in the scalar transaction; scalar snapshots without a profile preserve cached profiles and payment addresses through observed-to-owned adoption. SQLite folds explicit updates and deletions into its canonical identity blob so they survive reload. Identity placement never determines profile authority; this adds no database migration or IdentityEntry encoding change.
  • Persistence. The PR appends SQLite migration V023 and Room migration 16→17 (17.json), preserving the published migrations. SwiftData adds PersistentDashpayPaymentAddresses to live V5 while frozen V4 remains unchanged. Restored and synchronized Orchard metadata is validated and retained even without shielded spending support.
  • FFI. The tip exports resolve their wallet and seed inside panic boundaries. A send failure reported as unconfirmed keeps its do-not-retry contract. Shielded identity creation rejects an occupied local slot before spending; a local registration failure after on-chain creation preserves the identity ID and holds the slot through the existing nonretry host result.
  • Example apps: storage-explorer coverage for the new SwiftData model, identity deletion removing its rows, and ordinary shielded-send balances and Swift identity-creation funding scoped to account 0.

How Has This Been Tested?

  • Rust: public state-mutation races, profile-publication removal/replacement races, delayed own/contact profile synchronization across wallet replacement, and the read-only manager API are covered; 2,067 all-feature wallet library tests, 571 storage integration tests plus 440 storage library tests, 590 shielded FFI tests, 525 default-feature FFI tests, and 66 JNI tests passed (one intentionally ignored in each FFI configuration). The existing default-feature stale-generation and address-only profile-sync regressions also passed.
  • Kotlin: 581 SDK unit tests passed; the example app and Android migration tests compiled. Room/KSP generated v17, and the migration SQL matches all 36 exported tables while preserving representative existing rows.
  • Regression coverage: cold observed profile preservation through adoption, explicit observed-profile deletion, first-absence persistence (including a failing negative control with the prior equality shortcut), overlay ordering/ABI negotiation, profile deletion and replacement surviving SQLite reload; default/diversified/internal ordinary-account publication refusal and internal identity-account publication refusal, with external receiving addresses and other-wallet addresses still accepted, wallet removal and Clear paused at the prover boundary, with host deletion waiting until the operation ends, retained handles after same-ID recreation (including a funded replacement tip paused after source validation while stale public/apply/load/discovery mutations are refused), Clear/removal paused between preparation bind and flush, with persistence preceding host deletion; Clear invalidating a prepared address, occupied-slot creation preflight, post-broadcast identity ID/error preservation, tip-only and mixed-account ordinary-send balances in both hosts and Swift identity funding; valid Orchard metadata restored and retained through an unrelated identity snapshot without shielded spending support; address-only profile sync; and Swift contact-profile fetch failure rolling back profile, payment addresses, and identity scalars.
  • Migration checks: SQLite V001–V022 identities and rendered SQL are unchanged; V023 fingerprints pass. Swift schema inventory, frozen-schema comparisons, and 99 Python tests passed.
  • The exact wallet CI clippy command (all targets/features across wallet, storage, FFI, unified FFI/JNI; -D warnings), workspace formatting, and cargo check --workspace --all-targets --locked passed. Native Swift build and SwiftData tests require the Apple CI runners.

Breaking Changes

These are client-side only; there is no consensus or protocol change, so the title has no !.

  • C ABI. Profile authority uses an appended, size-negotiated on_persist_dashpay_profiles_fn extension. IdentityEntryFFI and ContactProfileRowFFI gained the payment addresses, and platform_wallet_manager_send_shielded_tip takes a *const ShieldedTipSourceFFI in place of account. Rebuild the xcframework and the JNI library together with host code.
  • Rust API. A scalar IdentityEntry.dashpay_profile == None is unknown/no update; explicit profile deletion uses PlatformWalletChangeSet.dashpay_profiles. The profile models and rs-sdk's ProfileFields gained the payment address fields. PaymentAddressUpdate moved to dash_sdk::platform::dashpay, and platform-wallet re-exports it. send_shielded_tip takes a ShieldedTipSource. DashPayView::{create,update}_profile_with_external_signer are now crate-private; use PlatformWallet::write_dashpay_profile, which checks tip addresses. PlatformWallet::wallet_manager and PlatformWalletManager::wallet_manager_arc now expose read-only handles. Raw IdentityWallet write getters are removed; live state writes use state_mut, state_mut_blocking, or try_state_mut, which hold the identity-placement lock through mutation and whole-manager replacement. state_mut and state_mut_blocking now return Result, rejecting removed/replaced handles with WalletNotFound; try_state_mut returns None for them. Account APIs use SHIELDED_IDENTITY_ACCOUNT_BASE, shielded_identity_account_index, is_shielded_identity_account, and prepare_shielded_identity_address; the corresponding C, Swift, Kotlin, and JNI entry points use the same identity-account naming. Tip send/resolve APIs keep their names.
  • Swift. PersistentIdentity.remove(in:identityId:) now throws, and sendShieldedTip takes source: in place of account:.
  • Kotlin. sendShieldedTip takes source: in place of account:.
  • Persistence. The migrations above are forward-only; downgrading a migrated database to an older SDK is not supported.

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Review history before 2026-09 is on #4616.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added shielded DashPay tips, including address preparation, username resolution, and sending from an identity or selected account.
    • DashPay profiles can now keep, set, or remove Core, Platform, and shielded payment addresses. These addresses are preserved when profiles are saved and restored.
    • Added APIs to inspect shielded account indices and retrieve profile payment addresses.
    • Added a Storage Explorer view for DashPay payment-address records.
  • Bug Fixes
    • Shielded balances now reflect only the selected account’s unspent notes.
    • Improved identity placement handling to avoid overwriting identities when verified slots conflict.
  • Documentation
    • Added guidance on shielded tips and profile payment addresses.

@PastaPastaPasta PastaPastaPasta added this to the v5.1.0 milestone Oct 5, 2026
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Walkthrough

This change adds DashPay payment-address fields, shielded tip APIs, and identity-slot placement updates across Rust, Kotlin, JNI, and Swift. It also updates persistence, schema migration, restore paths, and shielded balance queries to use account-scoped note data.

Changes: DashPay addresses, shielded tips, and identity placement

Layer / File(s) Summary
Schema and storage compatibility
packages/kotlin-sdk/sdk/src/main/kotlin/.../DashDatabase.kt, packages/kotlin-sdk/sdk/src/androidTest/.../DashDatabaseMigrationTest.kt, packages/rs-platform-wallet-storage/..., packages/swift-sdk/SCHEMA_RELEASES.md, packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift, packages/swift-sdk/schema-models.json, scripts/check-storage-explorer.sh
Kotlin Room moves to schema version 17 and adds payment-address columns. Rust storage adds entry_format and profile_format stamps with legacy/current decoders and migration coverage. Swift schema metadata now includes the payment-address sidecar model.
Profile address contracts and SDK wiring
packages/rs-platform-wallet/src/wallet/identity/types/..., packages/rs-sdk/src/platform/dashpay/profile.rs, packages/rs-platform-wallet-ffi/src/dashpay_profile.rs, packages/rs-unified-sdk-jni/src/dashpay.rs, packages/kotlin-sdk/sdk/src/main/kotlin/.../tokens/*, packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/DashPayProfile.swift, .../ManagedPlatformWallet.swift
Profile updates now support keep, set, and remove actions for core, platform, and shielded addresses. Rust, FFI, JNI, Kotlin, and Swift wrappers pass these fields through profile create and update calls.
Profile persistence and restore paths
packages/rs-platform-wallet-ffi/src/identity_persistence.rs, packages/rs-platform-wallet-ffi/src/persistence.rs, packages/rs-unified-sdk-jni/src/persistence.rs, packages/kotlin-sdk/sdk/src/main/kotlin/.../NativePersistenceBridge.kt, .../PlatformWalletPersistenceHandler.kt, packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/*, .../PlatformWalletPersistenceHandler.swift, ...Tests/DashPayPersistenceTests.swift
Identity and contact-profile persistence now store and restore payment addresses, and restore can include an identity-owned DashPay profile. Wallet-owned cached profiles are deleted when a later snapshot omits them. SwiftData stores addresses in a separate keyed entity.
Shielded tips and account-scoped balances
packages/rs-platform-wallet/src/wallet/shielded/*, packages/rs-platform-wallet-ffi/src/shielded_send.rs, .../shielded_sync.rs, packages/rs-unified-sdk-jni/src/funding.rs, packages/kotlin-sdk/sdk/src/main/kotlin/.../FundingNative.kt, .../PlatformWalletManager.kt, packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManagerShieldedSync.swift, packages/*/README.md, packages/*ExampleApp*/...SendTransaction*
The wallet adds dedicated shielded tip accounts, tip-address preparation, recipient resolution, send APIs, and account-index helpers. Shielded balance queries now use scoped account data and exclude unrelated notes in tests and example apps.
Verified identity placement and apply order
packages/rs-platform-wallet/src/wallet/identity/state/manager/*, .../network/discovery.rs, .../network/loading.rs, .../identity_handle.rs, packages/rs-platform-wallet/src/wallet/apply.rs, packages/rs-platform-wallet-storage/tests/integration/sqlite_identity_index_uniqueness.rs
Identity placement now rejects occupied slots, supports adopting verified identities into wallet slots, and changes apply order so removals happen before snapshots. Discovery, loading, and apply now coordinate through a shared placement lock and expanded tests cover conflicts and slot reuse.

Estimated code review effort: 5 (Critical) | ~120 minutes

Change: Feature

Suggested reviewers: thepastaclaw, llbartekll, quantumexplorer

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant KotlinOrSwiftSDK
  participant JNIorFFI
  participant PlatformWallet
  participant DashPayView

  App->>KotlinOrSwiftSDK: resolveShieldedTip(username)
  KotlinOrSwiftSDK->>JNIorFFI: resolveShieldedTip
  JNIorFFI->>PlatformWallet: resolve_shielded_tip
  PlatformWallet->>DashPayView: fetch current profile for username
  DashPayView-->>PlatformWallet: identityId + shielded address
  PlatformWallet-->>JNIorFFI: confirmed recipient
  JNIorFFI-->>KotlinOrSwiftSDK: ShieldedTipRecipient

  App->>KotlinOrSwiftSDK: sendShieldedTip(source, username, recipient, amount)
  KotlinOrSwiftSDK->>JNIorFFI: sendShieldedTip
  JNIorFFI->>PlatformWallet: send_shielded_tip
  PlatformWallet->>DashPayView: re-resolve username
  DashPayView-->>PlatformWallet: current recipient
  PlatformWallet->>PlatformWallet: validate source and expected recipient
  PlatformWallet-->>JNIorFFI: send result
  JNIorFFI-->>KotlinOrSwiftSDK: completion
Loading
Merge Risk: Moderate · previous review 2a2d1

The change adds shielded tips but leaves several edge cases that should be fixed before merge. After a shielded clear, a profile can publish a tip address that is no longer monitored. Tip funds can appear in the displayed shielded balance even though the ordinary send screens cannot spend them. An identity created from the shielded pool can end up on-chain but unregistered locally, while the call reports success. A direct identity move can bypass the lock that protects tip sends.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: adding DashPay shielded tip support with dedicated accounts. The raw summary and PR objectives confirm this. Shielded tip addresses, dedicated ZIP-32 tip accounts, rec…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: adding DashPay shielded tip support with dedicated accounts. The raw summary and PR objectives confirm this. Shielded tip addresses, dedicated ZIP-32 tip accounts, recipient resolution, and tip sending are all in the changeset. The title is specific and concise, and it follows a conventional commit style. It omits profile-address persistence and bindings, which are secondary to the main change.

Finishing Touches

Generate unit tests (beta)

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

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

Share

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · 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 Oct 5, 2026
@thepastaclaw

thepastaclaw commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

⛔ Final review complete — 7 blocking finding(s) (commit b9b2654) · triage: critical

PastaPastaPasta added a commit that referenced this pull request Oct 5, 2026
Live V4 adds PersistentDashpayPaymentAddresses, which sorts ahead of
PersistentIdentity and renumbers it from 13 to 14. Core Data embeds the
ordinal in generated column names, so the token-balance table's
Z13TOKENBALANCES foreign key becomes Z14TOKENBALANCES with its values
intact. validatePreservation normalized Z_<n> join-table names but not
the Z<n><NAME> column form, so the V1 -> V3 -> V4 and historical
V2 -> V3 -> V4 migrations were reported as removing a column
(DashModelMigrationTests, CI on #5288).

validatePreservation now keys columns by entity name for the
cross-store comparison; a dropped or type-converted column is still
rejected. layout()/evidence() keep their existing keys so recovery
journals written by earlier builds still verify.

Test: a renumbered copy of the dash-v1 fixture (entity inserted at 8,
join-table and generated columns renamed) passes; the same copy with
the column dropped or converted to VARCHAR is rejected.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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

@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

Verified the supplied findings against head 02460d6 and confirmed four issues involving identity-placement persistence, restart-safe submissions, identity-specific spending-account selection, and concurrent account binding. These are client-side defects, classified as suggestions under the supplied policy reserving blocking severity for consensus invariants. Validation was static: the supplied CI snapshot reports successful Rust workspace and Kotlin checks, skipped dedicated wallet tests, and Swift build/tests still in progress.

🟡 4 suggestion(s)

Review provenance

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

  • Triage: critical by gpt-6.1-sol (effort low) — The large, cross-language diff directly changes key derivation and dedicated account handling in packages/rs-platform-wallet/src/wallet/shielded/tips.rs, funds submission in packages/rs-platform-wallet-ffi/src/shielded_send.rs, and persisted-data migrations in SQLite, SwiftData, and Room.
  • 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 (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:206-207: Preserve corrected identity indices through changeset merging
  The new adoption path changes identity_index, but IdentityChangeSet::merge never copies that field into an existing entry. With SQLite FlushMode::Manual, a snapshot buffered at placeholder index 0 can therefore absorb the subsequent discovery snapshot at verified index 5 while retaining index 0. Both Buffer::normalize_identities and the final buffered merge use these semantics, so flush/reload restores the incorrect placement. The same stale slot also remains occupied during buffered admission checks, potentially rejecting another identity that discovery places into the freed slot.

  Make identity_index follow the latest snapshot alongside wallet_id. Add a SQLite regression that buffers an old-slot snapshot, adopts the identity into its verified slot, persists the resulting snapshot, then flushes and reloads; also verify that another identity can occupy the freed slot.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift:28-32: Restore outstanding tip submissions before enabling another send
  The submission guard and wallet map are memory-only, and each new process initializes the guard to ready. Kotlin's ShieldedTipSubmissions has the same lifecycle. Restarting after a broadcast with an unresolved outcome therefore removes the warning and permits the user to retry the same intended payment as a new transfer. A relay withholding confirmation is sufficient to create this ambiguity; process termination during broadcast also exposes it.

  Rust records pending transfer activity and can redrive the original transition, but transfer reserves individual input notes rather than a payment intent. Additional spendable notes can fund the retry, allowing both transfers to execute. Persist an unresolved intent before entering the native send, restore its guard before enabling submission, and reconcile it with the original activity or transition. Add process-recreation coverage with an ambiguous original transfer and additional spendable notes; the existing reopening tests retain the same in-memory owner.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/DashPayProfileView.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/DashPayProfileView.swift:39-44: Verify the identity index before selecting its tip spending account
  Rust's optional index getter returns recorded metadata, not a verified identity-to-account association. The mobile restore path constructs ManagedIdentity::new(identity, spec.identity_index), so a persisted placeholder zero becomes Some(0). The existing should_refuse_tip_account_for_a_placeholder_index_until_it_is_verified regression demonstrates an identity belonging at index 5 restored at index 0 while index 0's tip account is bound.

  Preparation rejects this association by checking the seed, but this balance/spending selector and Kotlin's corresponding selectors bypass that check. They can display index 0's funds as belonging to the restored identity and pass that account to the send API, which validates account keys but receives no source identity to verify. Resolve identity-specific tip accounts through a verified wallet operation, or disable these selectors until the association is verified. Extend the placeholder regression to cover balance lookup and spending-account selection, not only address preparation.

In `packages/rs-platform-wallet/src/wallet/shielded/tips.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/tips.rs:142-147: Make tip preparation an atomic augmentation of the bound account set
  The account snapshot and replacement bind are separate operations. Preparation can snapshot ordinary account 0, another task can finish binding accounts 0 and 1, and preparation can then bind its stale snapshot plus the tip account. bind_shielded automatically retains discovered and persisted tip accounts, but not omitted ordinary accounts. Consequently, register_locked removes account 1 from registration and purges its live subwallet state, contradicting preparation's ordinary-account preservation guarantee.

  The shield guard and coordinator install transaction serialize individual installations, not the preceding read-modify-write sequence. Serialize configuration changes across the snapshot and bind, or provide an augmentation operation that merges with the current registration inside the installation transaction. Add a deterministic interleaving regression proving that an ordinary account added during preparation remains bound.
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.

  • Seed verification runs while holding the wallet-manager read guard — The guard covers bounded synchronous derivation and verification with no network call or await inside the guarded block. Writers are briefly excluded, but the finding supplies no demonstrated hot-path or material contention problem; moving this work outside the lock is an optional optimization rather than a confirmed review defect.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

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

@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

Static verification confirms the original concurrent-bind race and buffered identity-index merge defect are fixed, and the reported occupied-placeholder spending case is now rejected before recipient resolution. Six client-side suggestions remain concerning restart recovery, stale source-account selection, identity replay, account preservation, and test isolation; no consensus-blocking defect was confirmed. No builds or tests were run, and the supplied exact-head CI snapshot still had most validation queued or pending.

🟡 6 suggestion(s)

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

🟡 Suggestion: Serialize shielded_add_account with the new shielded config lock
packages/rs-platform-wallet/src/wallet/platform_wallet.rs:1154-1160

Tip preparation now holds shielded_config_lock across its account snapshot and replacement bind, but shielded_add_account writes the same shielded_keys map without participating in that lock. Preparation can snapshot [0], an addition can persist and insert ordinary account 1, and preparation can then install its stale snapshot plus the tip account, overwriting the completed insertion while leaving its viewing-key row persisted. This breaks the new preparation helper's ordinary-account preservation guarantee even though the concurrent-bind case is fixed. Acquire the same configuration lock for the complete add operation, preserving the existing rule that host callbacks run outside the key-slot guard. The add API intentionally does not register accounts with the coordinator itself, so this finding concerns loss of its in-memory insertion, not a claim that it creates a coordinator registration. Extend the interleaving coverage to race preparation with this writer.

source: muse-spark-1.3-contributor (phase1-reviewer: rust-quality)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

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

  • Triage: critical by gpt-6.1-sol (effort low) — This large, intricate diff directly changes funds movement and dedicated ZIP-32 key/account handling in packages/rs-platform-wallet/src/wallet/shielded/tips.rs and packages/rs-platform-wallet-ffi/src/shielded_send.rs, as well as persisted-data migrations.
  • 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 (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/DashPayTabScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/DashPayTabScreen.kt:336-345: Invalidate and reverify the source account when an identity is re-slotted
  The lookup keys include the wallet wrapper, manager, and identity ID, but not the identity's placement. This PR allows discovery to move that same identity from placeholder index 0 to verified index 5 without replacing those objects. If discovery completes while this composition is alive, the cached result remains `0x40000000` and is still offered as that identity's dedicated source account. A blocking discovery can continue natively after its search screen is dismissed, so returning to DashPay before it finishes can expose this interleaving. The new Rust check does not reject the stale source: `verify_tip_account_owner` succeeds when slot 0 has become empty, and also succeeds if the rightful identity 0 later occupies it. A confirmed send can thus spend the retained account-0 funds rather than the selected identity's account-5 funds. Invalidate the lookup when verified placement changes and recheck the selected source identity/account association at submission; checking only the account's current occupant is insufficient. Add a regression resolving at placeholder 0, adopting into 5, and attempting a send with the old selection. The profile-screen lookup also needs placement-change invalidation.

In `packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/state/manager/lifecycle.rs:195-207: Carry identity relocation through changeset replay
  Adoption now changes bucket placement and identity coordinates, but `IdentityManager::apply_identity_entry` still updates an existing identity in place and returns without applying `wallet_id`, `identity_index`, or `location_index`. Replaying valid snapshots A@0, then adopted A@5, then newly admitted B@0 through the public `PlatformWallet::apply` or `PlatformWalletInfo::apply_changeset` API leaves A at slot 0 until B's fresh insertion overwrites it. A's state is lost and its reverse-index entry still points to slot 0, so `identity(A)` returns B. Promotion from the observed bucket likewise fails to reproduce the adoption. Normal startup reconstruction uses a different path, which limits the current impact, but the public replay API no longer reproduces the mutations introduced here. Apply relocation while preserving managed state and reverse-index consistency, reject unrelated occupied targets, and handle merged batches independently of identity-ID ordering when one entry frees another's slot. Add round-trip coverage for observed-identity promotion and A@0 → A@5 followed by B@0.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/SearchWalletsForIdentitiesScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/identity/SearchWalletsForIdentitiesScreen.kt:147-151: Preserve ordinary accounts during discovery-triggered rebinding
  This new refresh calls the replacement bind API with its default account list `[0]`. For a wallet already bound to ordinary accounts `[0, 1]`, Rust adds discovered and persisted tip accounts but does not retain omitted ordinary account 1. `NetworkShieldedCoordinator::register_locked` consequently removes account 1's registration and purges its live notes and watermark, so discovering identities unexpectedly stops an existing ordinary account from scanning. Swift preserves a snapshot of ordinary accounts, but its snapshot and replacement call are also outside the native configuration lock. Provide a refresh operation that reads the current configuration and adds discovered tip accounts atomically under `shielded_config_lock`, and use it from discovery rather than treating `[0]` as a complete replacement configuration. Keep full bind available for intentional replacement. Cover discovery refresh starting from `[0, 1]` and verify that both ordinary registrations survive.

In `packages/rs-platform-wallet/src/wallet/platform_wallet.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:1154-1160: Serialize shielded_add_account with the new shielded config lock
  Tip preparation now holds `shielded_config_lock` across its account snapshot and replacement bind, but `shielded_add_account` writes the same `shielded_keys` map without participating in that lock. Preparation can snapshot `[0]`, an addition can persist and insert ordinary account 1, and preparation can then install its stale snapshot plus the tip account, overwriting the completed insertion while leaving its viewing-key row persisted. This breaks the new preparation helper's ordinary-account preservation guarantee even though the concurrent-bind case is fixed. Acquire the same configuration lock for the complete add operation, preserving the existing rule that host callbacks run outside the key-slot guard. The add API intentionally does not register accounts with the coordinator itself, so this finding concerns loss of its in-memory insertion, not a claim that it creates a coordinator registration. Extend the interleaving coverage to race preparation with this writer.

In `packages/rs-platform-wallet/src/wallet/shielded/tips.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/tips.rs:258-263: Isolate the preparation pause hook by wallet instance
  The global pause hook is consumed using only the deterministic wallet ID. The concurrency regression, placeholder-index regression, and discovery/restoration regression all create independent testnet wallet instances from `MESSAGE_SIGNING_TEST_MNEMONIC`, so they share that ID. Under parallel execution, another test's preparation can remove the concurrency test's hook and signal `reached` while holding its own configuration lock. The intended preparation then runs without pausing, allowing the competing bind to complete inside the timeout and failing the regression despite correct production locking. Attach the hook to shared state belonging to the actual wallet instance, use an instance-specific token, or give the concurrency fixture a distinct deterministic mnemonic. The current wallet-ID key does not provide the parallel-test isolation claimed by the comment.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift:28-32: Restore outstanding tip submissions before enabling another send
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4185823786)
  The shared owner preserves the submission guard across sheet dismissal, but a new process reconstructs an empty wallet map and a `.ready` submission. Kotlin has the same lifecycle. After termination during an accepted-but-unconfirmed send, reopening therefore removes the uncertainty warning and permits the user to confirm the same payment again. Native pending activity and redrive records do not prevent this: note reservations exclude particular inputs, while `reserve_unspent_notes` can select other funded notes for a fresh transfer. The redrive transaction itself is armed only after an ambiguous broadcast result returns, so process loss during the call also cannot be treated as a recovered safe retry. Persist a network/wallet-scoped unresolved intent before entering native spending, restore its warning before enabling confirmation, and reconcile native activity or require explicit acknowledgment that another submission is a separate payment. Add process-recreation tests using newly constructed owners and sufficient independent notes to fund both attempts. The PR's pending maintainer decision is not an implemented recovery boundary.

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Re: the review's non-inline finding "Serialize shielded_add_account with the new shielded config lock" (platform_wallet.rs:1154-1160).

Confirmed and fixed in 93d4d3b. shielded_add_account now takes shielded_config_lock after its attachment check, before its key-slot read. Host callbacks still run outside the key-slot guard, and the lock order (config lock, then shield_guard / shielded_keys) is unchanged.

The new regression should_keep_an_added_account_during_tip_preparation pauses preparation after its snapshot, races shielded_add_account(1) against it, and checks that account 1 is still bound afterwards. The test fails without the lock.


🤖 Posted autonomously by Claude on behalf of pasta.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · 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 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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

@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

At head 6c88c31, the configuration-locking, pause-hook isolation, and identity-index merge fixes are present, but three client-side suggestions remain around merged replay, queued source-account selection, and restart-safe submission state; no consensus blocker was confirmed. All nine prior findings were independently reconciled, with the acknowledged balance-provenance follow-up kept deferred. Validation was static only: the supplied CI snapshot shows Rust workspace and Kotlin checks passing, the dedicated wallet job skipped, and PR Hygiene pending; the Swift failure log confirms “database is locked” in testCaptureHistoricalV2Fixture.

🟡 3 suggestion(s)

1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

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

  • Triage: critical by gpt-6.1-sol (effort low) — This large, intricate diff changes funds movement and key handling in packages/rs-platform-wallet-ffi/src/shielded_send.rs and packages/rs-platform-wallet/src/wallet/shielded/tips.rs, as well as persisted-state migrations across SQLite, SwiftData, and Room.
  • 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 (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet/src/wallet/apply.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/apply.rs:162-170: Carry identity relocation through changeset replay
  The new ordering handles sequential relocation, but it still evaluates occupancy against transient state rather than the merged batch's final survivors. Starting with A@0, merge the changesets from moving A to 5, removing A, and inserting B@5. IdentityChangeSet::merge retains both A's snapshot and tombstone, so this partition postpones A's removal. Replay moves A to 5, skips fresh B because A occupies 5, then removes A and returns success with B missing. B's subsequent key/contact entries cannot route, and applying the batch again can produce a different result.

  The relocation loop in identity/state/manager/apply.rs has another instance of the same final-state problem: A@0/B@1 ending at A@1/B@0 remains blocked and falls back to in-place updates. The public adoption API can produce those final snapshots through free slot 2, and SQLite's check_index_conflicts explicitly accepts a two-way swap, so replay can disagree with persistence even for a conflict-free final batch.

  Remove all tombstoned identities before placement and exclude their snapshots. Stage surviving relocations so valid cycles can be installed while preserving managed state and reverse-index consistency. Add regressions using actual merged mutation changesets, checking replay against the final persisted placement and checking repeated application.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ShieldedTipSheet.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ShieldedTipSheet.kt:95-99: Invalidate and reverify the source account when an identity is re-slotted
  The placement keys now refresh the account offered by the open sheet, but confirmation copies it into sendAccount before history.confirm suspends on Dispatchers.IO. Discovery can move the selected identity A from placeholder 0 to verified 5 during that suspension. Subsequent recomposition cannot change the account captured by the application-owned submission, so the native call still receives 0x40000000.

  Rust's verify_tip_account_owner accepts that account if slot 0 is empty, or verifies its rightful replacement B if B now occupies slot 0. Neither case establishes that the submitted account belongs to selected identity A. These are still wallet-owned funds, and explicitly spending a retired account is legitimate; the defect is silently using that pool from an identity-specific dedicated-account choice.

  Carry the expected source identity through the identity-scoped submission and verify its seed-derived association with the requested account before selecting notes. Preserve intentional retired-account spending through an explicitly account-based path. Add a regression that pauses recipient-history persistence, re-slots A, and verifies that the captured old source is rejected.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift:28-32: Restore outstanding tip submissions before enabling another send
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4185823786)
  The application-owned guard survives navigation, but its status and registry are memory-only. After process termination, forWallet creates a submission in ready without consulting persisted outgoing activity or recovery state. Kotlin's registry has the same lifetime boundary, and recipient confirmation history records the destination rather than the payment outcome.

  If the process exits after broadcast but before the result reaches the host, relaunch permits a fresh attempt while the first payment may already have executed or remain eligible for redrive. Native reservations protect the first payment's nullifiers, not the logical payment: operations::transfer selects other available notes without an unresolved-intent check. With another sufficient note set, both transfers can execute and pay the recipient twice. This is duplicate payment, not a consensus double-spend.

  Persist an unresolved intent before entering the native send, restore a conservative reconciliation state before enabling another attempt, and clear it only after a definitive outcome. Add process-recreation coverage with an unresolved first payment and enough other notes to fund another transfer; the current tests reuse the same submission owner.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · 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 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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

@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

The client-only diff preserves proof-verified recipient resolution and addresses the reported identity-replay, account-configuration locking, and changeset-merging defects. Three non-blocking concerns remain: two source-account relocation windows and loss of unresolved-payment guards after process restart; unverified balance attribution remains an explicitly separated follow-up. Validation was static only: git diff --check passed, and the supplied exact-head CI snapshot still had Kotlin build/tests and PR Hygiene pending.

🟡 3 suggestion(s)

3 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

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

  • Triage: critical by gpt-6.1-sol (effort low) — This large, intricate diff changes key derivation and viewing-key binding in packages/rs-platform-wallet/src/wallet/shielded/tips.rs, funds submission in packages/rs-platform-wallet-ffi/src/shielded_send.rs, and persisted profile encoding and migrations across SQLite, SwiftData, and Room.
  • 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 (antigravity below 15% reserve: weekly 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ShieldedTipSheet.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ShieldedTipSheet.kt:95-99: Invalidate and reverify the source account when an identity is re-slotted
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4190547321)
  The source account is copied into sendAccount before history.confirm suspends on Dispatchers.IO. Discovery can move the selected identity from placeholder slot 0 to verified slot 5 during that suspension. A subsequent Room update cannot change the captured argument, and the JNI/C send signatures carry the recipient identity but no expected source identity. Rust's verify_tip_account_owner accepts the emptied slot-0 account, so with sufficient retained notes the payment can spend account 0x40000000 instead of the selected identity's account-5 pool. This is a source-selection error, not an unauthorized-spending bypass: both pools remain wallet-owned. Carry the selected source identity and confirmed account through the identity-specific submission path, reject a changed association before spending, and require renewed review. Preserve explicitly selected retired-account spending separately. Add an interleaving regression that relocates the source while confirmation-history persistence is suspended.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/DashPayTabScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/DashPayTabScreen.kt:337-345: Invalidate and reverify the source account when an identity is re-slotted
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4187974162)
  The placement key fixes eventual cache invalidation, but there is also a window before Room delivers the changed placement. Native discovery updates the identity manager first; until the corresponding row reaches composition, tipAccountKey still matches the old result and the sheet can confirm that account as the selected identity's dedicated source. Reading the current prop at confirmation does not close this window. The native ownership check validates the account's current occupant, not the selected source identity, and deliberately permits an empty retired slot. Retaining that policy is reasonable, but this identity-selected flow should not silently substitute the retired pool. Keep the Room-key fix and validate the expected source identity/account association natively at submission. Cover relocation before the corresponding Room emission, separately from relocation after the sheet captures its argument.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift:28-32: Restore outstanding tip submissions before enabling another send
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4185823786)
  Every reconstructed submission starts ready, and both apps retain their per-wallet guards only in memory. Restarting after a broadcast with an unresolved outcome therefore enables another confirmation without restoring the previous sending/uncertain state. Native recovery does not make this payment-intent-safe: PendingRedrive is armed after an ambiguous result returns, and even a surviving record reserves only the original transaction's notes. reserve_unspent_notes can select other available notes for a fresh transfer, allowing both payments to execute if the user repeats the apparently unfinished tip. Persist an unresolved submission marker by network and wallet before invoking native send, restore it before enabling payment, and reconcile it with shielded activity/recovery state. Add reconstruction tests with a new submissions owner over the same durable state; the current reopening tests exercise only the existing owner. The description identifies a pending maintainer decision, but the current implementation still has this limitation.
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.

  • Track verified identity placement for tip-balance attribution — The restore path constructs ManagedIdentity::new(identity, spec.identity_index), so a historical placeholder zero becomes Some(0). Swift and Kotlin balance selectors consequently can attribute retained account-0 notes to an identity actually derived at index 5. Native seed checks reject preparation and spending while that incorrect identity occupies the slot, but do not verify the displayed balance. This is the concrete balance-display remainder explicitly separated into a follow-up in the author's response, not a new finding to reopen here.
    • Follow-up: Track derivation-verification provenance and expose an identity-aware tip-account resolver through the native bindings, with an unverified presentation state and placeholder-restore coverage.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 6, 2026
@PastaPastaPasta
PastaPastaPasta force-pushed the feat/dashpay-shielded-tips branch from 74a473f to 4451545 Compare October 15, 2026 03:25
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · 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 bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 15, 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

The configuration-locking, identity-replay, and changeset-merging fixes are present; three client-side suggestions remain concerning source-account association, restart recovery, and profile clearing. Static validation only: git diff --check passed, and no builds or tests were run. The supplied CI snapshot shows Kotlin and Swift schema/explorer checks passing, Rust workspace tests pending, and the dedicated Rust wallet job skipped.

🟡 3 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

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

  • Triage: critical by gpt-6.1-sol (effort low) — This large, intricate diff directly changes shielded funds submission in packages/rs-platform-wallet-ffi/src/shielded_send.rs, viewing-key and dedicated-account handling in packages/rs-platform-wallet/src/wallet/shielded/tips.rs, and persisted profile migrations across SQLite, SwiftData, and Room.
  • 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 (antigravity below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift`:
- [SUGGESTION] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift:3593-3595: Preserve the shared wallet's profile-clear semantics during persistence
  ManagedIdentity::set_dashpay_profile(None) explicitly clears the profile, sync_profiles emits that snapshot after confirming absence, and IdentityChangeSet::merge preserves None with last-write-wins semantics. This adapter instead leaves the previous profile row untouched; Kotlin's onPersistIdentityUpsert does the same. Although that interpretation predates this change, this PR adds owned-profile restoration that loads the retained row back into canonical ManagedIdentity state. A successfully cleared profile can consequently reappear after restart, including its cached shielded address. Apply an absent profile snapshot by deleting the cached owner profile and, on Swift, its owner-profile payment-address sidecar. If callers need a distinct unknown/no-update state, represent it explicitly rather than interpreting the authoritative snapshot differently in each adapter. Add a persist-profile, clear-snapshot, cold-restore regression for both hosts.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ShieldedTipSheet.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ShieldedTipSheet.kt:95-99: Invalidate and reverify the source account when an identity is re-slotted
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4190547321)
  Confirmation copies tipAccount into sendAccount before history.confirm suspends on Dispatchers.IO to commit preferences. Discovery can relocate the selected identity from placeholder slot 0 to verified slot 5 during that suspension. The placement-keyed lookup can subsequently refresh, but it cannot replace the value already captured by this submission. Native send_shielded_tip receives only the numeric source account, and verify_tip_account_owner accepts the old account when slot 0 is empty or contains its correctly derived owner. With available notes, the payment can therefore spend account-0 funds while the UI presents the source as the selected identity's dedicated account. Wallet ownership makes deliberate retired-account spending valid, but does not establish that this stale identity-specific selection was deliberate. Carry the expected source identity into an identity-aware native submission operation and validate its verified account association before selecting notes. Add a regression that pauses confirmation-history persistence, relocates the identity, and verifies that resuming cannot spend the obsolete source.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift:28-32: Restore outstanding tip submissions before enabling another send
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4185823786)
  Application ownership preserves the guard across navigation, but the wallet dictionary and submission status are entirely process-local. After termination during broadcasting or following an uncertain result, relaunch constructs a new submission in ready state without restoring the outstanding payment. Kotlin's application-owned submissions have the same boundary. Native recovery can reconcile or redrive the original transition, but reserve_unspent_notes selects available notes without deduplicating the recipient/amount intent; a fresh submission can use other notes and pay the recipient again. Persist an outstanding intent before invoking native send, restore it into an unresolved state before enabling another submission, and reconcile it against native activity before clearing the guard. The existing reopen tests retain the same submission owner; add a reconstruction regression using a new owner after an accepted-but-unconfirmed attempt.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

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

@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

The client-only account policy, persistence migrations, replay fixes, and owned-profile clearing are consistent with the intended design; no consensus or dependency-layering blockers were found. Three non-blocking issues remain: source-account association can change during asynchronous confirmation, unresolved submissions are forgotten after process restart, and Kotlin's new profile deletion crosses network boundaries. This was static verification only; the supplied exact-head CI snapshot still has Kotlin validation running and other checks pending or queued.

🟡 3 suggestion(s)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

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

  • Triage: critical by gpt-6.1-sol (effort low) — This large, intricate diff directly changes shielded key derivation and funds isolation in packages/rs-platform-wallet/src/wallet/shielded/tips.rs, payment submission in packages/rs-platform-wallet-ffi/src/shielded_send.rs, and persisted storage migrations across SQLite, SwiftData, and Room.
  • 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 (antigravity below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/PlatformWalletPersistenceHandler.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/PlatformWalletPersistenceHandler.kt:1746-1747: Scope owned-profile deletion to the snapshot network
  This new absent-profile branch calls `deleteProfilesByIdentity`, whose SQL filters only by identityId. However, DashpayProfileEntity is keyed by `(networkRaw, identityId)`, the present-profile branch writes using the resolved networkRaw, and restoration reads profiles using that network-qualified key. The example app shares one DashDatabase across network managers. If the same identity ID has cached profile rows on two networks, an authoritative absence on one network deletes both rows, including the other network's profile and payment addresses. Add a network-scoped DAO deletion and use the networkRaw already resolved for this snapshot. Extend the clearing regression with a second-network profile row and assert that it survives.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ShieldedTipSheet.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ShieldedTipSheet.kt:95-99: Invalidate and reverify the source account when an identity is re-slotted
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4190547321)
  The placement-keyed lookup refreshes subsequent compositions, but this submission captures only a numeric source account before `history.confirm` suspends on Dispatchers.IO. Discovery can move identity A from restored placeholder index 0 to verified index 5 during that suspension, and the resumed submission still passes account 0x40000000. Native `verify_tip_account_owner` accepts that account when slot 0 is empty, or when its correctly derived identity subsequently occupies it; the send boundary receives no selected source identity to detect that the account no longer matches A. Allowing explicitly selected retired accounts is valid, but it does not preserve this UI's promise to spend from the selected identity's dedicated account. Carry the selected source identity and expected account association into the native identity-specific send operation and reject a changed association before selecting funds, while preserving explicit retired-account spending separately. Add a regression that pauses confirmation persistence, re-slots A, and resumes the captured submission.

In `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ShieldedTipSubmission.swift:28-32: Restore outstanding tip submissions before enabling another send
  (existing thread: https://github.com/dashpay/platform/pull/5288#discussion_r4185823786)
  Both example apps keep submission guards exclusively in memory, so a new process creates an empty registry and initializes each wallet to ready. Termination after broadcast but before observing its outcome, or after an unconfirmed result, therefore removes the warning and permits an apparent retry as a new payment. Native activity/redrive records protect the original transaction, and note reservations exclude its selected inputs, but `operations::transfer` independently selects other available notes for a new call; neither mechanism deduplicates the user's payment intent. With sufficient additional notes, both transfers can execute. Persist an unresolved submission marker before entering native spending, restore it before enabling another send, and reconcile it against durable activity/recovery information or require explicit acknowledgement of the unresolved payment. Add a cold-recreation regression: the existing reopen tests retain the same application-owned guard and do not exercise process restart. The PR description's open maintainer decision does not establish an implemented recovery path or an agreed exclusion.

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

PastaPastaPasta and others added 5 commits November 23, 2026 14:29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd placement

- Tip preparation returns an address only once the viewing key it stored is
  durable, refusing one that a competing flush drained and lost.
- Live identity registration takes identity placement before the wallet
  manager, so it cannot fill a slot a tip send checked as retired.
- A profile write releases its lifecycle, coordinator and placement locks
  while the host signer prompts, and retakes and rechecks them before the
  SDK broadcasts, so a prompt never holds back removal or Clear.
- An own-profile sync discards its result for an identity whose profile was
  written while the fetch was in flight.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lease the registry before signing

A profile tombstone travels only in the overlay callback; a host without it
cannot apply the deletion, so the round fails before it opens instead of
being acknowledged. The profile write clones the wallet out of the handle
registry before waiting on the host signer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…visible

sendShieldedTip returns a completed native send even if the caller was
cancelled, and a profile write whose wallet has no Room network fails the
round instead of acknowledging a deletion it never applied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… network

An identity row on another network is a conflict that fails the round, never
a row an upsert or removal adopts, and new rows take the callback network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Re the review on add77376, Keep an older profile fetch from overwriting a confirmed write (profile.rs:104-118, not inline): fixed in a8a82eb. DashPayState now counts the profile writes stored in this process (profile_writes, bumped on a successful set_dashpay_profile). sync_profiles records each identity's count before fetching and skips the writeback for any identity whose count moved, so a fetch that saw absence can no longer tombstone a newer write, and a fetch that saw an older profile can no longer restore it over one. The next sweep reads the write back. Test: should_keep_a_profile_written_while_an_older_fetch_was_in_flight. It covers both a delayed absent response and a delayed superseded one, in the same generation, and checks that the confirmed write is the last stored changeset. It fails without the check.

The Swift build failure was the V4→V5 migration test expecting the entity set from before the v5.2-dev merge, which added PersistentLockedOutpoint to the unreleased V5 (63f4b4b).


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

@github-actions

github-actions Bot commented Nov 23, 2026 •

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.

@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 2 only (queue backlog)

Changes requested: 4 blockers

  • The Rust wallet tests fail to compile after merging with v5.2-dev — packages/rs-platform-wallet/src/wallet/platform_wallet.rs:549-551 (new)
    Impact: The required Rust workspace check stops before running the tests because a masternode fixture still uses the manager write accessor this PR removes.
  • Release teardown locks before invoking the host profile signer — packages/rs-platform-wallet/src/wallet/platform_wallet.rs:3446-3448 (carried)
    Impact: A host that checks signing-key availability on a queue already waiting for wallet removal can hang both the profile write and removal before any signature is requested.
  • Verify the viewing-key write is durable before returning a tip address — packages/rs-platform-wallet/src/wallet/shielded/tips.rs:171-181 (thread, carried)
    Impact: A Rust host using SQLite Manual mode can publish a tip address that its wallet cannot scan on seedless restart because the viewing key never reached disk.
  • Scope scalar payment-address mutations to the callback wallet's network — packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift:3753-3767 (thread, carried)
    Impact: A Swift client using unscoped persistence can lose another network's cached identity and payment addresses if the emitting wallet's network cannot be resolved.

New on this head: This revision orders live identity registration against tip spending, adds a write counter to profile sync, releases the FFI registry before profile signing, and preserves confirmed Kotlin tip results across cancellation. The Rust workspace check failed to compile the merge result against v5.2-dev; Kotlin, Rust wasm32, and the Swift frozen-schema check passed, while the native Swift build and dedicated Rust wallet tests were skipped.

A pattern across this PR's review rounds

This is review round 34, and the PR has drawn 38 blocking findings so far. 3 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. Slot safety depends on each caller taking the right lock (1 new in this round, 4 earlier finding(s))

prepare_shielded_identity_address and send_shielded_tip rely on identity_placement to keep a checked slot stable, but the code that inserts or moves an identity does not itself enforce that boundary. The fixes have had to close one route at a time, from stale wallet handles to live registration, and the new regression tests lock_for_placement without exercising an insertion that could bypass it. That lock orders local writes; it does not reserve the slot that shielded_identity_create_from_pool checks before spending.

Already tracked: #5950

In this round: The registration race test passes even if registration bypasses the placement lock

Suggested decision (redesign the component): Make IdentityWallet own local slot changes: the operation that inserts or moves an identity must take identity_placement and check the wallet generation itself, rather than handing callers locks and relying on them to use those locks before writing. Demonstrate the boundary by racing a real registration against a tip operation that has already checked the slot. Keep the reservation across proving and broadcast deferred under #5950; this PR should guarantee ordering of local slot changes, not an exclusive claim before broadcast.

🔴 4 blocking | 🟡 1 suggestion(s)

Still open from earlier rounds (2)

  • 🔴 Blocking: Verify the viewing-key write is durable before returning a tip address — packages/rs-platform-wallet/src/wallet/shielded/tips.rs:171-181 (thread)
  • 🔴 Blocking: Scope scalar payment-address mutations to the callback wallet's network — packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift:3753-3767 (thread)
Follow-up candidates (optional) (1)

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

🟡 Suggestion: Profile sync counts a deletion even when the host rolls it back
Impact: Swift and Kotlin callers refreshing a deleted profile can get a positive change count while the old profile and payment address remain cached.
packages/rs-platform-wallet/src/wallet/identity/network/profile.rs:123-127

The new FFI preflight and Room rollback correctly reject an unapplied tombstone, but the public sync result still counts it. When persister.store fails, set_dashpay_profile restores the previous profile without advancing the checked flag or write counter, but returns (). sync_profiles unconditionally increments changed, which the C export and mobile SDKs return as a successful count. Have the setter return its store outcome so sync can propagate the failure or count only applied changes. Keep that sync result separate from the outcome of a profile write already confirmed on-chain.

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

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The diff adds shielded funds movement and per-identity key derivation in wallet/shielded/tips.rs, coordinates those operations with wallet teardown and identity moves, and changes persisted address encoding in V023__profile_address_encoding.rs.
  • Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
  • New since the last final review (add77376): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed; 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-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): Slot safety depends on each caller taking the right lock. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Make `IdentityWallet` own local slot changes: the operation that inserts or moves an identity must take `identity_placement` and check the wallet generation itself, rather than handing callers locks and relying on them to use those locks before writing. Demonstrate the boundary by racing a real registration against a tip operation that has already checked the slot. Keep the reservation across proving and broadcast deferred under #5950; this PR should guarantee ordering of local slot changes, not an exclusive claim before broadcast. If that decision is not yours to make, say so to the PR's author or maintainer.

These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet/src/wallet/platform_wallet.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:549-551: The Rust wallet tests fail to compile after merging with v5.2-dev
  Impact: The required Rust workspace check stops before running the tests because a masternode fixture still uses the manager write accessor this PR removes.
  The merge result cannot compile the `platform-wallet` library tests. Base PR #5889 added `removed_wallet_is_an_error_not_a_panic`, which removes its fixture via `wallet.wallet_manager().blocking_write().remove_wallet(...)`. This PR changes that accessor to return `WalletManagerReader`, which exposes reads only. The [Rust workspace job](https://github.com/dashpay/platform/actions/runs/45201721643/job/137787497131) reports `error[E0599]: no method named blocking_write` at `masternode/key_candidates.rs:263`. The branches merge without a textual conflict, so update the fixture when integrating the base: retain the owning manager and remove the wallet through its lifecycle API without reopening public write access.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: When Rust workspace CI checks the merge of this head into v5.2-dev, it compiles the `platform-wallet` library tests, including `removed_wallet_is_an_error_not_a_panic`. The test calls `wallet.wallet_manager().blocking_write()` at `masternode/key_candidates.rs:263`, but the merged accessor returns `&WalletManagerReader`, which has no `blocking_write` method. CI reports E0599 and cannot compile the library tests._
- [BLOCKING] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:3446-3448: Release teardown locks before invoking the host profile signer
  Impact: A host that checks signing-key availability on a queue already waiting for wallet removal can hang both the profile write and removal before any signature is requested.
  The short registry lookup and the release around `sign` fix the signing-prompt path, but profile create and update can still deadlock during key selection. Both call `profile_signing_key` after the initial admission; `first_available` reaches `AdmittedProfileSigner::can_sign_with`, which forwards to the synchronous `VTableSigner` callback while `held` still owns the generation read guard. If that callback needs a host queue waiting for manager removal, removal needs the write side of the same guard, and the async signing timeout has not started. `should_fence_profile_publication_against_wallet_replacement` pauses in this exact callback and asserts that removal waits; the new prompt test calls `sign` directly. Run host availability checks on the identity snapshot outside teardown admission, then reacquire and revalidate before proceeding, and cover the full create/update path with removal completing while the callback is pending.

In `packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs:2347-2358: The registration race test passes even if registration bypasses the placement lock
  Impact: A future change can restore the live slot race without failing the new regression test.
  The test polls `lock_for_placement()` directly and checks that the fixture wallet exists after releasing the reader. It never inserts an identity, so reverting all four registration callers to manager-only locking would leave the test green. Exercise a production registration path through local insertion, or make local insertion the shared operation under test, and assert that the slot stays empty until the placement reader releases it.

In `packages/rs-platform-wallet/src/wallet/shielded/tips.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/tips.rs:171-181: Verify the viewing-key write is durable before returning a tip address
  (carried; thread: https://github.com/dashpay/platform/pull/5288#discussion_r4658859131)

In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift:3753-3767: Scope scalar payment-address mutations to the callback wallet's network
  (carried; thread: https://github.com/dashpay/platform/pull/5288#discussion_r4658859144)

Comment on lines +549 to +551
/// Read the shared wallet manager. Mutations use [`Self::state_mut`].
pub fn wallet_manager(&self) -> &WalletManagerReader {
&self.wallet_manager_reader

@thepastaclaw thepastaclaw Nov 23, 2026 •

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.

✅ Resolved at b9b2654e; see the replies below.

🔴 Blocking: The Rust wallet tests fail to compile after merging with v5.2-dev
Impact: The required Rust workspace check stops before running the tests because a masternode fixture still uses the manager write accessor this PR removes.

The merge result cannot compile the platform-wallet library tests. Base PR #5889 added removed_wallet_is_an_error_not_a_panic, which removes its fixture via wallet.wallet_manager().blocking_write().remove_wallet(...). This PR changes that accessor to return WalletManagerReader, which exposes reads only. The Rust workspace job reports error[E0599]: no method named blocking_write at masternode/key_candidates.rs:263. The branches merge without a textual conflict, so update the fixture when integrating the base: retain the owning manager and remove the wallet through its lifecycle API without reopening public write access.

Raised on code unchanged since the last review, and confirmed by an independent pass: When Rust workspace CI checks the merge of this head into v5.2-dev, it compiles the platform-wallet library tests, including removed_wallet_is_an_error_not_a_panic. The test calls wallet.wallet_manager().blocking_write() at masternode/key_candidates.rs:263, but the merged accessor returns &WalletManagerReader, which has no blocking_write method. CI reports E0599 and cannot compile the library tests.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 34c44dd. The merge fixtures that write manager state now go through test-only write and blocking_write accessors on WalletManagerReader, which are #[cfg(test)]. The public reader stays read-only, and its compile_fail doctest still holds. cargo clippy --all-targets -D warnings and the full platform-wallet suite (2275 tests) pass on the restacked head.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

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.

Resolved (re-reviewed at b9b2654e): Confirmed: the masternode fixture's blocking_write resolves to the #[cfg(test)] method, and production WalletManagerReader still exposes no write accessor. This addresses the reported E0599.

Comment on lines +3446 to +3448
fn can_sign_with(&self, key: &IdentityPublicKey) -> bool {
self.inner.can_sign_with(key)
}

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.

🔴 Blocking: Release teardown locks before invoking the host profile signer
Impact: A host that checks signing-key availability on a queue already waiting for wallet removal can hang both the profile write and removal before any signature is requested.

The short registry lookup and the release around sign fix the signing-prompt path, but profile create and update can still deadlock during key selection. Both call profile_signing_key after the initial admission; first_available reaches AdmittedProfileSigner::can_sign_with, which forwards to the synchronous VTableSigner callback while held still owns the generation read guard. If that callback needs a host queue waiting for manager removal, removal needs the write side of the same guard, and the async signing timeout has not started. should_fence_profile_publication_against_wallet_replacement pauses in this exact callback and asserts that removal waits; the new prompt test calls sign directly. Run host availability checks on the identity snapshot outside teardown admission, then reacquire and revalidate before proceeding, and cover the full create/update path with removal completing while the callback is pending.

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

Comment on lines +2347 to +2358
async fn should_order_live_identity_registration_after_a_placement_reader() {
use futures::FutureExt;
let (wallet, _, _, _) = tip_race_fixture("tips_live_registration").await;
let placement = wallet.identity.identity_placement.read().await;
let mut registering = Box::pin(wallet.identity.lock_for_placement());
assert!(
registering.as_mut().now_or_never().is_none(),
"registration must wait for the placement reader"
);
drop(placement);
let (_placement, wm) = registering.await;
assert!(wm.get_wallet_info(&wallet.wallet_id()).is_some());

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.

🟡 Suggestion: The registration race test passes even if registration bypasses the placement lock
Impact: A future change can restore the live slot race without failing the new regression test.

The test polls lock_for_placement() directly and checks that the fixture wallet exists after releasing the reader. It never inserts an identity, so reverting all four registration callers to manager-only locking would leave the test green. Exercise a production registration path through local insertion, or make local insertion the shared operation under test, and assert that the slot stays empty until the placement reader releases it.

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

Comment on lines +1128 to +1134
let coordinator = self.resolve_shielded_coordinator(coordinator).await?;
// Fence generation teardown across attachment validation, host
// viewing-key persistence, and coordinator/handle installation.
let _lifecycle = self.core().generation_payment_guard().await;
let _config = self.shielded_config_lock.lock().await;
self.bind_shielded_locked_unfenced(seed, accounts, &coordinator)
.await

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.

Deferred (re-reviewed at 0b25205c): The generation guard orders bind and account addition against wallet removal, not against the existing split between native Clear and host deletion. Your planned #5934 rebase is the tracked change for that shared boundary; this head does not yet contain it.

Comment on lines +175 to +177
self.persister()
.flush()
.map_err(|e| PlatformWalletError::Persistence(e.to_string()))?;

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.

Still applies (re-reviewed at 0b25205c): The mark catches the competing wallet flush in your test, but the public SQLite bulk commit goes directly through flush_inner and reports errors in CommitReport rather than in that ledger. A fatal drop on that path still lets preparation certify an empty buffer.

Comment on lines +481 to +499
let option = PLATFORM_WALLET_STORAGE.with_item(wallet_handle, move |wallet| {
let wallet = wallet.clone();
let input = ProfileUpdate {
display_name,
public_message,
avatar_url,
avatar_bytes: avatar_bytes_vec,
core_payment_address,
platform_payment_address,
shielded_address,
};

block_on_worker(async move {
let signer: &VTableSigner = &*(signer_addr as *const VTableSigner);
wallet
.write_dashpay_profile(&id, input, signer, do_create)
.await
})
});

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.

Still applies (re-reviewed at 0b25205c): The registry clone and signing-prompt test verify the fixes for sign. The full-write replacement test pauses earlier in can_sign_with and explicitly checks that removal waits there; that synchronous host call still holds the generation guard.

Comment on lines +386 to +391
let _operation = coordinator.operation_guard().await;
let _placement = self.identity.identity_placement.read().await;
let account = self.tip_source_account(seed, source).await?;
#[cfg(test)]
test_hooks::before_spend(self).await;
self.shielded_transfer_to(

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.

Resolved (re-reviewed at 0b25205c): All four insertion sites now take placement before the manager lock and obtain the current generation's state there. That closes the local race without conflating it with the reservation in #5950.

Comment on lines 3896 to 3904
let descriptor = FetchDescriptor<PersistentIdentity>(
predicate: #Predicate { $0.identityId == identityId }
)
if let existing = try? backgroundContext.fetch(descriptor).first {
// A failed fetch fails the changeset rather than reading as an
// absent row, which would strand the identity and its sidecar.
if let existing = try backgroundContext.fetch(descriptor).first {
try PersistentDashpayPaymentAddresses.removeOwned(in: backgroundContext,
networkRaw: existing.networkRaw, ownerIdentityId: identityId)
backgroundContext.delete(existing)

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.

Still applies (re-reviewed at 0b25205c): Your scalar-only test confirms that a known devnet/testnet mismatch is rejected. With the unscoped initializer and an unstamped or unreadable wallet row, the new guard instead reports no conflict and still allows the identity-ID-only mutation.

recipient: org.dashfoundation.dashsdk.tokens.ShieldedTipRecipient,
amount: Long, source: org.dashfoundation.dashsdk.tokens.ShieldedTipSource,
memo: String? = null,
): Unit = teardownGate.op {

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.

Resolved (re-reviewed at 0b25205c): The shared handoff captures the JNI result before dispatching back to the caller, so the existing cancellation test covers the boundary that sendShieldedTip now uses.

Comment on lines +2978 to +2981
if let (Some(profiles), Some(cb)) = (
changeset.dashpay_profiles.as_ref(),
self.tracked_masternodes_callbacks.persist_dashpay_profiles,
) {

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.

Resolved (re-reviewed at 0b25205c): Your FFI preflight rejects an unsupported tombstone before the round opens, and the staged Room callback now throws so the transaction rolls back. Neither path marks that deletion as stored.

PastaPastaPasta and others added 7 commits November 23, 2026 19:19
# Conflicts:
#	packages/rs-platform-wallet/src/wallet/platform_wallet.rs
v5.2-dev's OUTPOINT_LOCKS took capability bit 1 << 16 and the next
persistence extension slots, so SHIELDED_STATE_WIPE moves to 1 << 17 and
its slot follows the outpoint-lock slots. The new identity-shield
recipient FFI path resolves its coordinator through the wallet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s wallet's removal

Spends, shields, top-ups, identity creates and debit abandons took only
the coordinator admission, which a removal shares, and never checked
that the wallet was still attached. A retained Arc<PlatformWallet> could
derive keys, select notes and broadcast after the removal returned.

Every durable shielded operation now takes its locks through
lock_for_shielded_operation: the generation's lifecycle gate (which a
removal takes exclusively), shield_guard for a shield-class operation,
then the admission and the attachment check. A funding checks under the
shield_guard it holds to its end, before anything is built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce pending request restores

A funding now checks the wallet is still attached as soon as it runs
under shield_guard, before any funding resolution. Restoring pending
private contact requests is refused for a removed wallet without holding
the generation gate across the store read. The new identity-shield
recipient FFI path refuses an unconfigured manager before any work, as
its siblings do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v5.2-dev's summary was stale against its manifest, which fails the
Kotlin SDK job's parity check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lded-tips

Restack the tips work on the shielded lifecycle boundary (#5934). The
manager now owns the coordinator, so the tip and profile entry points
drop their coordinator parameter and resolve it through the wallet.
Tip preparation, tip sends and profile publication run under the
coordinator's admission in place of this branch's operation guard and
clear generation, and a prepared tip account is tied to the Clear epoch
it was admitted under. The DashPay profile persistence slot follows the
shielded wipe slot in the persistence extension.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lded-tips

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 23, 2026 •

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.

@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: 7 blockers

  • The profile tests no longer compile without the shielded feature — packages/rs-platform-wallet/src/wallet/identity/network/profile.rs:1004-1006 (new; not shown inline, see below)
    Impact: Developers running the default-feature wallet library tests cannot run the profile regressions, including the one that covers address-only profiles without shielded spending.
  • A matching non-master key can select an identity's shielded account — packages/rs-platform-wallet/src/wallet/shielded/tips.rs:76-79 (new; not shown inline, see below)
    Impact: A caller preparing an address or sending as an identity can use the account at a discovered or restored index even when that index did not derive the identity's master authentication key.
  • A same-slot replacement identity can reuse an address preparation it never proved — packages/rs-platform-wallet/src/wallet/shielded/tips.rs:314-329 (new; not shown inline, see below)
    Impact: After an identity is reloaded or replaced at the same ID and slot without the proved key, a caller can still publish its previously prepared address.
  • A wallet handle rolled back during restore can still send a tip after reload — packages/rs-platform-wallet/src/wallet/shielded/tips.rs:374-383 (new; not shown inline, see below)
    Impact: A Rust host that retains a wallet during a failed multi-wallet restore can later spend from the reloaded wallet through the obsolete handle, outside the replacement's teardown and placement guards.
  • Release teardown locks before invoking the host profile signer — packages/rs-platform-wallet/src/wallet/platform_wallet.rs:3655-3657 (thread, carried)
    Impact: A profile create or update can deadlock with wallet removal when the host's key-availability callback waits on the queue performing removal.
  • Verify the viewing-key write is durable before returning a tip address — packages/rs-platform-wallet/src/wallet/shielded/tips.rs:172-177 (thread, carried)
    Impact: A host using SQLite Manual mode can publish a tip address even though a seedless restart cannot recover the viewing key needed to scan it.
  • Scope scalar payment-address mutations to the callback wallet's network — packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift:3761-3764 (thread, carried)
    Impact: An unscoped Swift host can delete another network's cached identity and payment addresses when it cannot read the emitting wallet's network.

New on this head: This head restacks DashPay shielded tips on #5934: wallet operations use the manager-owned coordinator, and Clear holds exclusive admission through the host wipe. Kotlin SDK tests, the Swift frozen-schema check, and Rust wasm32 checks passed; the Rust workspace test job was still running. One additional suggestion was left out under the 10-comment limit.

A pattern across this PR's review rounds

This is review round 35, and the PR has drawn 43 blocking findings so far. 11 of them share 4 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.

1. Slot safety still depends on each caller (2 earlier finding(s))

The live registration paths now call lock_for_placement and current_wallet_info_mut, but IdentityManager::add_identity still relies on the caller to take the lock and check the generation. A tip send can trust that a checked slot stays empty only if every writer follows that order, and the registration test can pass without any registration actually doing so.

Already tracked: #5950

2. The restack lost the proof behind the account (2 new in this round, 1 earlier finding(s))

The restack kept the account number and Clear epoch in PreparedTipAccount but left out #5905's binding to the seed-derived master authentication key. That lets a raw hash match stand in for the master-key proof during preparation and spending, and lets an unchanged slot stand in for that proof at publication even when the current identity record no longer carries the key.

In this round: A matching non-master key can select an identity's shielded account; A same-slot replacement identity can reuse an address preparation it never proved

3. Wallet detachment is not enforced on every exit (1 new in this round, 5 earlier finding(s))

The shared shielded admission trusts shielded_detached, which remove_wallet_with_teardown sets but the rollback in load_from_persistor does not. Dropping the explicit generation check in send_shielded_tip brings back the retained-handle problem through a different route: the old handle holds its own generation's lock while the reused wallet_id leads it to replacement state.

Already tracked: #5936

In this round: A wallet handle rolled back during restore can still send a tip after reload

4. Host signing is only partly outside teardown locks (2 earlier finding(s))

write_dashpay_profile holds teardown admission across the SDK call and releases it around individual signer methods rather than around all calls into the host. AdmittedProfileSigner drops admission for sign but not for can_sign_with, so the lock conflict survives one step earlier, during key selection.

Already tracked: #6189

Suggested decision (redesign the component): Make IdentityWallet own the local slot changes that tip operations depend on: the insert or move itself must take placement and check the live wallet generation, rather than returning locks for callers to assemble. Tip operations should use that same live-generation boundary and preserve #5905's master-key proof against the current identity record, on top of #5934's Clear admission. Demonstrate the boundary with a real registration racing a tip operation that has already checked the slot. Keep the slot reservation across proving and broadcast deferred under #5950.

🔴 7 blocking | 🟡 2 suggestion(s)

9 finding(s) not shown inline (GitHub refused the PR diff as too large)

🔴 Blocking: Release teardown locks before invoking the host profile signer
Impact: A profile create or update can deadlock with wallet removal when the host's key-availability callback waits on the queue performing removal.
packages/rs-platform-wallet/src/wallet/platform_wallet.rs:3655-3657

Moving sign outside admission fixes the signing prompt, but a host can still hang before that prompt starts. Both profile write branches select an eligible key through profile_signing_key while AdmittedProfileSigner.held owns the generation read guard. first_available calls can_sign_with, which invokes the host's C vtable synchronously without releasing that guard. If the callback needs the host queue that is waiting for remove_wallet, removal cannot finish because it needs the exclusive side of the same guard. This probe is not covered by the asynchronous signing timeout. Check availability on an identity snapshot outside admission, then re-admit and validate the selected key and publication state before proceeding. Exercise removal while the availability callback is pending, not just while sign is pending.

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

🔴 Blocking: Verify the viewing-key write is durable before returning a tip address
Impact: A host using SQLite Manual mode can publish a tip address even though a seedless restart cannot recover the viewing key needed to scan it.
packages/rs-platform-wallet/src/wallet/shielded/tips.rs:172-177

The ledger mark fixes the competing wallet flush in your regression, but preparation can still certify a lost key when the host uses SQLite's documented commit_writes() API. Once bind buffers a new viewing key, a concurrent bulk commit can drain that wallet's batch through flush_inner and encounter a non-retryable transaction error. handle_flush_error drops the drained batch, and the failure reaches the bulk commit report but never reaches WalletPersister's ledger. Preparation then flushes an empty buffer, sees unchanged counters, and records the address as prepared. Coordinator admission excludes Clear, not this backend commit. Account for every drain at the backend boundary or verify the expected viewing key in committed storage before recording preparation. Cover a failed public commit_writes() with a newly introduced account.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-astra (phase2-reviewer: general, architecture-layering, rust-quality)

🔴 Blocking: Scope scalar payment-address mutations to the callback wallet's network
Impact: An unscoped Swift host can delete another network's cached identity and payment addresses when it cannot read the emitting wallet's network.
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift:3761-3764

Your scalar-only regression closes the known-network mismatch, but an unresolved network still permits the same deletion. The public raw-SDK configuration accepts a model container with no network, and walletNetwork uses try?, so a missing wallet row or failed lookup leaves callbackNetworkRaw nil. onOtherNetwork then returns false for every row. A removal-only changeset fetches the globally keyed identity by ID and deletes it and its sidecars using the matched row's network; no overlay callback has to run. Require a known emitting network before applying scalar mutations, propagate wallet-lookup errors, and make the existing-identity upsert lookup throwing as well. Add a scalar-only regression with an unresolved emitting wallet and a resident identity on another network.

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

🔴 Blocking: The profile tests no longer compile without the shielded feature
Impact: Developers running the default-feature wallet library tests cannot run the profile regressions, including the one that covers address-only profiles without shielded spending.
packages/rs-platform-wallet/src/wallet/identity/network/profile.rs:1004-1006

The restack adds a tenth argument to the PlatformWallet::new calls here and at line 1127. Both fixtures are in #[cfg(test)] mod address_patch_tests, but the constructor's tenth parameter is compiled only with feature = "shielded". The crate defaults are bls and eddsa, so cargo test -p platform-wallet --lib has a nine-argument constructor and two ten-argument calls. Gate both arguments with #[cfg(feature = "shielded")], as the shared fixture in test_support.rs does, rather than gating the tests.

Confirmed by an independent pass: Running the platform-wallet library tests with the crate's default features compiles both address-patch fixtures but excludes the shielded coordinator parameter from PlatformWallet::new. Both fixtures still pass a tenth argument, so the test binary fails to compile.

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

🔴 Blocking: A matching non-master key can select an identity's shielded account
Impact: A caller preparing an address or sending as an identity can use the account at a discovered or restored index even when that index did not derive the identity's master authentication key.
packages/rs-platform-wallet/src/wallet/shielded/tips.rs:76-79

The restack drops part of the upstream change it says it carries. #5905 (b60876aed0, merged on v5.1-dev and present in this head's second parent b0cf3b7198) requires the matching key to be ECDSA_SECP256K1, AUTHENTICATION, and MASTER. Its negative test covers a matching hash-only key and a matching key below MASTER. This head accepts either: verify_identity_index compares only public_key_hash(), and DPP returns the stored hash for ECDSA_HASH160. Both prepare_shielded_identity_address and send_shielded_tip(ShieldedTipSource::Identity(...)) rely on the weaker check. Discovery's hash lookup can remain broader; the missing hunk is #5905's separate proof before the wallet uses the slot. Preserve that predicate and regression and use the same proof for both entry points.

Raised on code unchanged since the last review, and confirmed by an independent pass: The restack violates the missing-upstream-hunk rule: it carries #5905 but omits, without a declared reason, the requirement that the matching key be a full ECDSA secp256k1 MASTER authentication key. It also drops the upstream regression that rejects matching hash-only and below-MASTER keys.

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

🔴 Blocking: A same-slot replacement identity can reuse an address preparation it never proved
Impact: After an identity is reloaded or replaced at the same ID and slot without the proved key, a caller can still publish its previously prepared address.
packages/rs-platform-wallet/src/wallet/shielded/tips.rs:314-329

write_dashpay_profile can authorize an old preparation after the underlying identity record changes. A caller can replace an identity through the placement-locked wallet state APIs, or reload it with a different or incomplete key set while keeping the same ID and index. The placement lock orders the operations but does not invalidate the earlier preparation: this check compares only identity ownership, slot, account, and Clear epoch. The #5905 implementation in b0cf3b7198 retained master_key_hash, checked standing_account_of against the current record, and tested removing and adding back an identity without the proved key. The restack also drops the public prepared_shielded_identity_account getter that exposed that check, so Rust callers of the incoming API no longer compile. Preserve the getter and standing-proof check, and reuse that check under publication admission. Tightening the initial seed check alone does not fix later reuse.

Confirmed by an independent pass: A caller can prepare an address, then replace the managed identity's key set through state_mut without changing its ID or slot. If a valid profile-signing key remains, write_dashpay_profile can broadcast the old address even though the current record no longer carries the key that proved the slot.

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

🔴 Blocking: A wallet handle rolled back during restore can still send a tip after reload
Impact: A Rust host that retains a wallet during a failed multi-wallet restore can later spend from the reloaded wallet through the obsolete handle, outside the replacement's teardown and placement guards.
packages/rs-platform-wallet/src/wallet/shielded/tips.rs:374-383

load_from_persistor publishes each wallet before processing the next one (manager/load.rs:636), so a concurrent wallet reader can retain the first handle before a later entry fails to restore. The documented retry can then load the same wallet ID again. The rollback removes the first handle from the map and calls remove_from_wallet_manager directly, without taking its teardown gate or marking it shielded-detached. This restack removes the tip send's explicit is_current_generation() check; locks.admit(self) checks only that detached flag. The retained handle can therefore bind with the same seed against the replacement's ID-keyed wallet state, then use the shared coordinator's funded account while holding only the obsolete generation's locks. Keep the live-generation check at admission, and make rollback retire published handles under the teardown boundary or defer publication until the load succeeds. Cover a handle obtained before a later restore entry fails.

Confirmed by an independent pass: A caller can retain a wallet through get_wallet while a multi-wallet restore is in progress, before a later wallet's restore error rolls it back. After the documented retry reloads that wallet ID, the retained handle can bind with the same seed and broadcast a tip from the funded account while holding only the old generation's gate. Removing the replacement can then purge the pending spend's recovery record while the broadcast outcome is still unknown.

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

🟡 Suggestion: The registration race test passes even if registration bypasses the placement lock
Impact: The regression stays green if a production registration path stops protecting a slot that a tip send has already checked.
packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs:2270-2281

The production insertions currently take placement, but this test polls lock_for_placement() directly and ends by asserting the wallet exists. Replacing the helper with a bare manager write at a production registration call site would not change any assertion. Drive a real registration to its local insertion step, hold a placement reader, and check that the slot stays empty until the reader releases it and is filled afterward.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-astra (phase2-reviewer: general, rust-quality)

🟡 Suggestion: The tip race tests observe a simulated deletion after Clear instead of the host wipe
Impact: The tip preparation and spend regressions can pass their host-state assertions without checking when Clear invokes its actual wipe callback.
packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs:158-165

The restack moves host deletion into wipe_shielded_state, but this mock only clears serve and serve_subwallets there. Both tip race helpers still clear the captured stored rows and append "host deletion" after manager.clear_shielded() returns. The event ordering and empty captured state therefore describe the test's post-return cleanup, not the wipe now inside Clear. Clear the captured shielded writes and record the event inside wipe_shielded_state; keep the post-return simulation only for wallet removal.

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

Still open from earlier rounds (4)

  • 🔴 Blocking: Release teardown locks before invoking the host profile signer — packages/rs-platform-wallet/src/wallet/platform_wallet.rs:3655-3657 (thread)
  • 🔴 Blocking: Verify the viewing-key write is durable before returning a tip address — packages/rs-platform-wallet/src/wallet/shielded/tips.rs:172-177 (thread)
  • 🔴 Blocking: Scope scalar payment-address mutations to the callback wallet's network — packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift:3761-3764 (thread)
  • 🟡 Suggestion: The registration race test passes even if registration bypasses the placement lock — packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs:2270-2281 (thread)
Follow-up candidates (optional) (1)

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

🟡 Suggestion: The tip guide shows a coordinator argument the preparation API no longer accepts
Impact: A Rust integrator following the guide gets an argument-count error when preparing an identity address.
packages/rs-platform-wallet/docs/SHIELDED_TIPS.md:34

The restack moved coordinator selection into PlatformWallet. Line 34 still passes a third argument, but the current call is wallet.prepare_shielded_identity_address(seed, identity_id).await. Update the example and explain that shielded support must be configured on the owning manager and the ordinary accounts bound first.

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

Review provenance

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

  • Triage: critical by gpt-6.2-sol (effort low) — The diff adds a shielded funds-transfer path in wallet/shielded/tips.rs and changes per-identity Orchard key handling and wallet lifecycle synchronization, alongside persisted-data migrations such as V023__profile_address_encoding.rs.
  • 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)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • New since the last final review (0b25205c): 4 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 4 confirmed; 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-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
Several findings on this PR share an underlying cause (the review's "pattern" section): Slot safety still depends on each caller; The restack lost the proof behind the account; Wallet detachment is not enforced on every exit; Host signing is only partly outside teardown locks. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Make `IdentityWallet` own the local slot changes that tip operations depend on: the insert or move itself must take placement and check the live wallet generation, rather than returning locks for callers to assemble. Tip operations should use that same live-generation boundary and preserve #5905's master-key proof against the current identity record, on top of #5934's Clear admission. Demonstrate the boundary with a real registration racing a tip operation that has already checked the slot. Keep the slot reservation across proving and broadcast deferred under #5950. If that decision is not yours to make, say so to the PR's author or maintainer.

These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet/src/wallet/identity/network/profile.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/network/profile.rs:1004-1006: The profile tests no longer compile without the shielded feature
  Impact: Developers running the default-feature wallet library tests cannot run the profile regressions, including the one that covers address-only profiles without shielded spending.
  The restack adds a tenth argument to the `PlatformWallet::new` calls here and at line 1127. Both fixtures are in `#[cfg(test)] mod address_patch_tests`, but the constructor's tenth parameter is compiled only with `feature = "shielded"`. The crate defaults are `bls` and `eddsa`, so `cargo test -p platform-wallet --lib` has a nine-argument constructor and two ten-argument calls. Gate both arguments with `#[cfg(feature = "shielded")]`, as the shared fixture in `test_support.rs` does, rather than gating the tests.

  _Confirmed by an independent pass: Running the platform-wallet library tests with the crate's default features compiles both address-patch fixtures but excludes the shielded coordinator parameter from `PlatformWallet::new`. Both fixtures still pass a tenth argument, so the test binary fails to compile._

In `packages/rs-platform-wallet/src/wallet/shielded/tips.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/tips.rs:76-79: A matching non-master key can select an identity's shielded account
  Impact: A caller preparing an address or sending as an identity can use the account at a discovered or restored index even when that index did not derive the identity's master authentication key.
  The restack drops part of the upstream change it says it carries. #5905 (`b60876aed0`, merged on `v5.1-dev` and present in this head's second parent `b0cf3b7198`) requires the matching key to be `ECDSA_SECP256K1`, `AUTHENTICATION`, and `MASTER`. Its negative test covers a matching hash-only key and a matching key below MASTER. This head accepts either: `verify_identity_index` compares only `public_key_hash()`, and DPP returns the stored hash for `ECDSA_HASH160`. Both `prepare_shielded_identity_address` and `send_shielded_tip(ShieldedTipSource::Identity(...))` rely on the weaker check. Discovery's hash lookup can remain broader; the missing hunk is #5905's separate proof before the wallet uses the slot. Preserve that predicate and regression and use the same proof for both entry points.

  _Raised on code unchanged since the last review, and confirmed by an independent pass: The restack violates the missing-upstream-hunk rule: it carries #5905 but omits, without a declared reason, the requirement that the matching key be a full ECDSA secp256k1 MASTER authentication key. It also drops the upstream regression that rejects matching hash-only and below-MASTER keys._
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/tips.rs:314-329: A same-slot replacement identity can reuse an address preparation it never proved
  Impact: After an identity is reloaded or replaced at the same ID and slot without the proved key, a caller can still publish its previously prepared address.
  `write_dashpay_profile` can authorize an old preparation after the underlying identity record changes. A caller can replace an identity through the placement-locked wallet state APIs, or reload it with a different or incomplete key set while keeping the same ID and index. The placement lock orders the operations but does not invalidate the earlier preparation: this check compares only identity ownership, slot, account, and Clear epoch. The #5905 implementation in `b0cf3b7198` retained `master_key_hash`, checked `standing_account_of` against the current record, and tested removing and adding back an identity without the proved key. The restack also drops the public `prepared_shielded_identity_account` getter that exposed that check, so Rust callers of the incoming API no longer compile. Preserve the getter and standing-proof check, and reuse that check under publication admission. Tightening the initial seed check alone does not fix later reuse.

  _Confirmed by an independent pass: A caller can prepare an address, then replace the managed identity's key set through `state_mut` without changing its ID or slot. If a valid profile-signing key remains, `write_dashpay_profile` can broadcast the old address even though the current record no longer carries the key that proved the slot._
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/tips.rs:374-383: A wallet handle rolled back during restore can still send a tip after reload
  Impact: A Rust host that retains a wallet during a failed multi-wallet restore can later spend from the reloaded wallet through the obsolete handle, outside the replacement's teardown and placement guards.
  `load_from_persistor` publishes each wallet before processing the next one (`manager/load.rs:636`), so a concurrent wallet reader can retain the first handle before a later entry fails to restore. The documented retry can then load the same wallet ID again. The rollback removes the first handle from the map and calls `remove_from_wallet_manager` directly, without taking its teardown gate or marking it shielded-detached. This restack removes the tip send's explicit `is_current_generation()` check; `locks.admit(self)` checks only that detached flag. The retained handle can therefore bind with the same seed against the replacement's ID-keyed wallet state, then use the shared coordinator's funded account while holding only the obsolete generation's locks. Keep the live-generation check at admission, and make rollback retire published handles under the teardown boundary or defer publication until the load succeeds. Cover a handle obtained before a later restore entry fails.

  _Confirmed by an independent pass: A caller can retain a wallet through `get_wallet` while a multi-wallet restore is in progress, before a later wallet's restore error rolls it back. After the documented retry reloads that wallet ID, the retained handle can bind with the same seed and broadcast a tip from the funded account while holding only the old generation's gate. Removing the replacement can then purge the pending spend's recovery record while the broadcast outcome is still unknown._
- [BLOCKING] packages/rs-platform-wallet/src/wallet/shielded/tips.rs:172-177: Verify the viewing-key write is durable before returning a tip address
  (carried; thread: https://github.com/dashpay/platform/pull/5288#discussion_r4658859131)

In `packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs:158-165: The tip race tests observe a simulated deletion after Clear instead of the host wipe
  Impact: The tip preparation and spend regressions can pass their host-state assertions without checking when Clear invokes its actual wipe callback.
  The restack moves host deletion into `wipe_shielded_state`, but this mock only clears `serve` and `serve_subwallets` there. Both tip race helpers still clear the captured `stored` rows and append `"host deletion"` after `manager.clear_shielded()` returns. The event ordering and empty captured state therefore describe the test's post-return cleanup, not the wipe now inside Clear. Clear the captured shielded writes and record the event inside `wipe_shielded_state`; keep the post-return simulation only for wallet removal.
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/shielded/viewing_key_bind_tests.rs:2270-2281: The registration race test passes even if registration bypasses the placement lock
  (carried; thread: https://github.com/dashpay/platform/pull/5288#discussion_r4668933040)

In `packages/rs-platform-wallet/src/wallet/platform_wallet.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/platform_wallet.rs:3655-3657: Release teardown locks before invoking the host profile signer
  (carried; thread: https://github.com/dashpay/platform/pull/5288#discussion_r4668933030)

In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletPersistenceHandler.swift:3761-3764: Scope scalar payment-address mutations to the callback wallet's network
  (carried; thread: https://github.com/dashpay/platform/pull/5288#discussion_r4658859144)

Comment on lines +1128 to +1134
let coordinator = self.resolve_shielded_coordinator(coordinator).await?;
// Fence generation teardown across attachment validation, host
// viewing-key persistence, and coordinator/handle installation.
let _lifecycle = self.core().generation_payment_guard().await;
let _config = self.shielded_config_lock.lock().await;
self.bind_shielded_locked_unfenced(seed, accounts, &coordinator)
.await

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.

Deferred (re-reviewed at b9b2654e): The boundary you deferred to #5934 is now present on this head: bind and account addition hold shared admission through persistence, and Clear holds exclusive admission through the host wipe. No additional guard is needed on this thread.

Comment on lines +549 to +551
/// Read the shared wallet manager. Mutations use [`Self::state_mut`].
pub fn wallet_manager(&self) -> &WalletManagerReader {
&self.wallet_manager_reader

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.

Resolved (re-reviewed at b9b2654e): Confirmed: the masternode fixture's blocking_write resolves to the #[cfg(test)] method, and production WalletManagerReader still exposes no write accessor. This addresses the reported E0599.

Comment on lines +481 to +499
let option = PLATFORM_WALLET_STORAGE.with_item(wallet_handle, move |wallet| {
let wallet = wallet.clone();
let input = ProfileUpdate {
display_name,
public_message,
avatar_url,
avatar_bytes: avatar_bytes_vec,
core_payment_address,
platform_payment_address,
shielded_address,
};

block_on_worker(async move {
let signer: &VTableSigner = &*(signer_addr as *const VTableSigner);
wallet
.write_dashpay_profile(&id, input, signer, do_create)
.await
})
});

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.

Resolved (re-reviewed at b9b2654e): The FFI now clones the wallet before waiting on the worker, and the asynchronous signature request releases admission and rechecks it before returning. The earlier synchronous availability probe is covered on the wallet-side thread.

@QuantumExplorer

Copy link
Copy Markdown
Member

Closing this in favour of smaller pull requests against v5.1-dev, so profile payment addresses and shielded tips can ship in 5.1. Thank you for this work: the design here and in #5709 is what the new pull requests are built from, and the commits that carry your code name you as co-author.

Where each part went:

Part of this pull request Now in
Profile payment addresses in the wallet, storage, FFI and Swift SDK #6124 (merged)
Preparing an identity's shielded account from the apps #6094 (merged)
Profile address editor, iOS #6094 (merged)
Profile address editor, Android #6146 (merged)
Tip resolve and send, with the wallet owning the decisions (#5709's design) #6191
Swift, JNI and Kotlin wrappers for tips #6192
Tip screens, iOS and Android (#5711) #6198, #6197
SHIELDED_TIPS.md a "Shielded tips to a DashPay username" section in packages/rs-platform-wallet/README.md (#6191)

Not carried over, because tips on v5.1-dev work without them:

If one of these should still land, a pull request with just that part would be welcome.

🤖 Posted by Claude Code

PastaPastaPasta and others added 4 commits November 24, 2026 03:00
…identity signer

Shielded identity creation no longer holds the generation gate or the
Clear admission across its build, which proves the bundle and then asks
an external signer for each key's proof of possession. It drops them
once its notes are reserved and witnessed and takes them again after the
build, refusing a wallet removed or a Clear completed in between before
anything is recorded or broadcast.

Also:
- a drain retry checks removal before it restores a pending checkpoint,
  so a retained handle writes nothing into a same-id replacement;
- shielded payment paths refuse a removed wallet as
  WalletRemovedBeforeSend, which hosts read as nothing sent;
- a failed load retires each wallet it had published the way removal
  does, so a handle obtained during the load runs no shielded operation;
- the identity-to-recipient FFI export resolves only the wallet and
  leaves input validation and readiness to the wallet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… into HEAD

# Conflicts:
#	packages/rs-platform-wallet/src/wallet/platform_wallet.rs
…e refused drain retries unresolved

A failed load's rollback now drops a published wallet's live shielded
registration without purging its store state, so signed recovery
records an earlier process saved survive for the next load. The
coordinator is resolved under the wallet's teardown gate and
shield_guard, so one installed during the load is released too.

A drain retry refused because its wallet was removed returns before the
outcome bookkeeping, so it reports no NotSent for a lock an earlier
attempt may have broadcast.

The identity-create FFI export reports WalletRemovedBeforeSend as
NotFound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Re-closed: I reopened this by mistake while trying to retrigger CI, before I saw it had been closed in favour of the split pull requests. Sorry for the noise.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

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.

3 participants