Skip to content

feat: shield from an identity and top up an identity from the shielded pool in KotlinExampleApp - #6147

Merged
QuantumExplorer merged 5 commits into
v5.1-devfrom
feat/kotlin-example-identity-shield-and-shielded-top-up
Nov 23, 2026
Merged

QuantumExplorer merged 5 commits into
v5.1-devfrom
feat/kotlin-example-identity-shield-and-shielded-top-up

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

KotlinExampleApp could not move credits between an identity and the wallet's shielded pool, though the Kotlin SDK already had both calls. This adds the two screens SwiftExampleApp has, and the lists that show an interrupted one again after the app is killed:

  • Send → Send From → Identity shields an identity's credits into the wallet's own shielded address (type 21, Swift SH-21).
  • Identity → Top Up → Shielded Balance tops up an identity from the shielded pool (type 22, Swift SH-22).
  • Shielded Activity → In-Progress Identity Shields and Top Up → Pending Shielded Top-Ups list unfinished ones after a restart (Swift SH-23).

Before: Send to your own shielded address offered Shielded and Platform only; Top Up offered Platform addresses only.
After: Send offers Identity (send.source.identity, then send.identitySourcePicker); Top Up offers Shielded Balance (topup.fundingSource.shielded). A returned call reads "submitted", never "success"; one that may have gone through says "do not retry" and is listed.

Issue being fixed or feature implemented

Parity with SwiftExampleApp for transitions 21 and 22, including recovery after process death. Related but separate: #5896 (v5.2-dev) binds a shield to a third-party address; this PR only uses the existing self-shield call on 5.1.

What was done?

KotlinExampleApp

  • SendTransactionScreen: FundSource.IDENTITY and SendFlow.IDENTITY_TO_SHIELDED, an identity picker over the wallet's identities with a balance, the fee floor (FeeKind.ShieldFromIdentity) shown as "Fee (at least)", the self-shield recipient check shared with type 15, and the tapped identity re-checked at dispatch. Back is disabled while a send proves.
  • ShieldedActivityScreen + new IdentityShieldRecoverySection: reads shieldedIdentityDebitRecoveryRecords on open, on resume, after each shielded sync result for the wallet and after Stop Retrying. A failed read keeps the last records. Check Now runs syncShieldedNow; Stop Retrying confirms the warning, then calls abandonShieldedIdentityDebit(acknowledgePossibleExecution = true).
  • TopUpIdentityScreen: a Shielded Balance source, offered when account 0's spendable balance Rust announces is known and above zero. It has a DASH amount field, shows the minimum fee (kind 4) as "at least", and re-reads the balance at the tap. The result section replaces the form. Pending Shielded Top-Ups lists the identity's pending kind 9 rows, with Check Now.
  • ShieldedIdentityFlows.kt: wording and outcome routing, ported from SendViewModel.swift, ShieldedIdentityDebitRecoveryView.swift and TopUpIdentityView.swift.
  • AccessiblePicker: optional per-option test tags.
  • Send source tags are now lowercase (send.source.core, ...) to match Swift's ids. Nothing in the repo referenced the old ones.

Kotlin SDK

  • DashSdkError.PlatformWallet.IdentityBalanceUnavailable for native code 58. It used to fall through to Generic.
  • ShieldedDao.observePendingIdentityTopUps(walletId, identityId). This is a query only, so there is no schema change.

Docs: Kotlin TEST_PLAN.md rows SH-21, SH-22, SH-23 (same ids as Swift; they were free). Two new parity capabilities, shielded.shield_from_identity and shielded.identity_top_up_from_pool, with PARITY_SUMMARY.md regenerated.

Public interface changes (Kotlin SDK): two additions, no removals. DashSdkError.PlatformWallet.IdentityBalanceUnavailable is new; code 58 used to surface as PlatformWallet.Generic(58, ...). ShieldedDao.observePendingIdentityTopUps is new. See Breaking Changes for what code 58 means for existing callers.

In-flight payments run on ShieldedIdentityPaymentCoordinator (application scope, one slot per kind, wallet and identity), not in the screen. A rotation or tab switch while a proof runs therefore neither drops the outcome nor allows a second payment.

Deliberate difference from Swift: the Kotlin screens do not compare amount plus fee with the identity's local balance or with the notes. Swift's views do. Rust already refuses a shortfall before saving or building anything: type 21 against the identity's proved balance, type 22 in note selection. A second copy in Kotlin would break the "wrappers marshal, they do not decide" rule. Kotlin gates only on what it shows (an identity or amount entered, the fee known). Follow-ups:

No Rust, FFI or JNI code changed. The JNI descriptors for the four calls match FundingNative and the Swift call shapes.

How Has This Been Tested?

  • ./gradlew :app:testDebugUnitTest --tests '*ShieldedIdentityFlowsTest' --tests '*ShieldedIdentityPaymentCoordinatorTest' --tests '*ShieldedTokenPurchaseTest': 14 + 4 + 8 pass.
  • ./gradlew :sdk:testDebugUnitTest --tests '*ShieldedIdentityTopUpActivityPersistenceTest' --tests '*DashSdkErrorTest' --tests '*ShieldedIdentityDebitRecoveryRecordTest': 2 + 38 + 3 pass. This includes a pending kind 9 row being listed after a restart.
  • ./gradlew :sdk:compileDebugAndroidTestKotlin :app:compileDebugKotlin: clean.
  • python3 scripts/check_sdk_parity_manifest.py --write-summary and python3 -m unittest discover -s scripts/tests: OK.

Not yet verified

  • The instrumented tests ran only in CI's x86_64 emulator job (not locally; the shared emulator was busy). On 69cf5cf, FfiSmokeTest.identityShieldAndShieldedTopUpSymbolsBindAndRejectInvalidInput passed, and ShieldedIdentityFlowsFfiTest failed on its expected error type, which 7f63d90 fixes. Its rerun on the new head is pending.
  • Emulator runs of SH-21, SH-22 and SH-23 against testnet, including a process kill with a record pending, and rotation or tab switching while a proof runs. Neither screen has been opened on a device.

Breaking Changes

None at the consensus or protocol level, so no !. One source-compatibility change for Kotlin SDK callers: native code 58 now maps to the new DashSdkError.PlatformWallet.IdentityBalanceUnavailable instead of PlatformWallet.Generic(58, ...). An exhaustive when over the sealed PlatformWallet needs a branch for it, and a handler that caught code 58 as Generic should catch IdentityBalanceUnavailable instead. Its meaning: the identity's balance could not be read with a proof, so nothing was saved or sent.

Checklist:

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · a53ad9b

  • Bots — thepastaclaw not yet — /skip-bots proceeds without the ones not yet reported
  • Self-review — post /self-reviewed
  • Reviewer requests paused — your 5 review slots are occupied; this PR is excluded from reviewers' queues. Required approvals still count without a slot.
  • Build running
  • Approvals
    • sdk-parity — you own it
    • kotlin-sdk (packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/di/AppContainer.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/services/shielded/ShieldedIdentityPaymentCoordinator.kt and 15 more) — HashEngineering

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

…d pool in KotlinExampleApp

Ports SwiftExampleApp's SH-21, SH-22 and SH-23 to KotlinExampleApp.

- Send: Send From > Identity shields from an identity's credit balance
  into the wallet's own shielded address (type 21). A returned call is
  "submitted"; one that may have gone through is "not confirmed yet".
- Shielded Activity lists In-Progress Identity Shields from Rust's
  durable records, with Check Now and Stop Retrying behind the warning,
  so an interrupted shield is visible again after a restart.
- Top Up Identity gets a Shielded Balance source (type 22) and lists the
  identity's pending top-ups from the pool (new Room query), also after
  a restart.
- Kotlin SDK maps native code 58 to IdentityBalanceUnavailable.
- FfiSmokeTest and a new instrumented test bind the four JNI calls.

Whether the identity or the notes cover amount plus fee stays Rust's
refusal against the proved balance; the screens do not compare them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@QuantumExplorer QuantumExplorer added this to the v5.1.0 milestone Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next included review available in 20 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 149d1d4 and a53ad9b.

Files selected for processing: 19

  • docs/sdk/sdk-parity-manifest.json
  • packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/di/AppContainer.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/services/shielded/ShieldedIdentityPaymentCoordinator.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/components/AccessiblePicker.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/IdentityShieldRecoverySection.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedActivityScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedIdentityFlows.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/services/shielded/ShieldedIdentityPaymentCoordinatorTest.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/shielded/ShieldedIdentityFlowsTest.kt
  • packages/kotlin-sdk/PARITY_SUMMARY.md
  • packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt
  • packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/ShieldedIdentityFlowsFfiTest.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/dao/ShieldedDao.kt
  • packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/errors/DashSdkErrorTest.kt
  • packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/persistence/ShieldedIdentityTopUpActivityPersistenceTest.kt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Share

@QuantumExplorer
QuantumExplorer marked this pull request as ready for review November 23, 2026 12:53
@thepastaclaw

thepastaclaw commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

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

@github-actions

Copy link
Copy Markdown
Contributor

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

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

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (queue backlog)

Changes requested: 7 blockers

  • Rotating or switching tabs during a shielded top-up can let the user pay twice — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:383-418 (new)
    Impact: A user who returns to the restored form while a payment is proving can submit the same amount again and spend a second set of notes plus another fee.
  • An unavailable shielded balance silently switches the draft to transparent funding — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:164-179 (new)
    Impact: A user who entered a Platform-address amount before choosing Shielded Balance can tap the same Top Up Balance button and spend transparent funds without explicitly switching back.
  • After restart, Top Up can hide a payment the wallet can still send — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:139-146 (new)
    Impact: After a failed activity write and an app restart, a user can see no pending warning and submit a replacement even though the original top-up can still execute.
  • Send can keep hiding a funded identity after its saved balance changes — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt:245-253 (new)
    Impact: A user whose identity receives credits while Send is open can remain unable to select it, and a top-up result can keep showing the pre-payment balance after Room saves the new one.
  • A valid one-credit top-up is reported as 0 DASH — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedIdentityFlows.kt:235-246 (new)
    Impact: A user who submits the advertised minimum of 0.00000000001 DASH can spend a nonzero amount and a fee while the result and pending row report a zero-amount top-up.
  • Identity Send accepts an editable recipient that the wallet call cannot validate — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt:789-809 (new)
    Impact: When a user enters a recipient for an identity-funded shield, only the ExampleApp's separate precheck ensures the entered destination agrees with the self-shield the wallet will build.
  • Check Now can crash a transparent-only build when a pending row is retained — packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:217 (new)
    Impact: A user who replaces a shielded build with the supported --no-shielded build while keeping app data can crash Top Up by tapping Check Now on a retained pending row.

PR #6147 adds identity-funded self-shielding, shielded identity top-ups, and recovery views to KotlinExampleApp using the existing Rust wallet operations. The Kotlin SDK x86_64 emulator check passed, with no failed code checks reported; PR Hygiene and the automated review were pending, and CI did not exercise the funded ExampleApp flows or process-death recovery. One lower-priority suggestion was omitted under the ten-finding limit.

🔴 7 blocking | 🟡 3 suggestion(s)

Review provenance

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

  • Triage: normal by gpt-6.2-sol (effort low) — The Kotlin changes add substantial UI, dispatch, and recovery logic around existing shield and top-up calls, but do not change how Rust validates or moves funds, selects notes, or persists wallet state.
  • Phase 1 reviewers: not run (skipped for throughput: 34 PRs queued, above the 10 limit)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt`:
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:383-418: Rotating or switching tabs during a shielded top-up can let the user pay twice
  Impact: A user who returns to the restored form while a payment is proving can submit the same amount again and spend a second set of notes plus another fee.
  The first payment can finish without the restored screen ever showing its result. The draft is `rememberSaveable`, but `isSubmitting` and `shieldedOutcome` live only in the composition, and the job runs in `rememberCoroutineScope`. Back is disabled, but `MainScreen` still allows tab switches with save and restore, and Android rotation recreates the Activity. Once blocking JNI starts, cancellation does not stop the Rust payment; `TeardownGate.op` can instead discard the result when it dispatches back to the cancelled caller. The pending-only list does not guard submission and excludes the activity once Rust marks it confirmed. Rust's `shield_guard` serializes calls but does not deduplicate them, so the second call can select different notes. Keep the job, dispatch guard, and result in a retained owner keyed by wallet and identity, and have the reopened screen observe the original attempt. Apply the same lifetime handling to the new Type 21 Send path, and test recreation and tab changes while a native payment is in flight.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:164-179: An unavailable shielded balance silently switches the draft to transparent funding
  Impact: A user who entered a Platform-address amount before choosing Shielded Balance can tap the same Top Up Balance button and spend transparent funds without explicitly switching back.
  Losing the shielded balance snapshot can change both the funding source and the amount the button will submit. `offersShielded` is false for zero and for `null`, including before the first balance emission after restoration. The effect overwrites the saved shielded selection, the picker disappears, and the Platform branch can immediately enable submission from the independently saved `amountText`. That branch calls `topUpFromAddresses`, which uses transparent funding addresses. Keep the user's selected source visible and disable its submission while unavailable, as Send does; switching funding sources must require an explicit choice.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:139-146: After restart, Top Up can hide a payment the wallet can still send
  Impact: After a failed activity write and an app restart, a user can see no pending warning and submit a replacement even though the original top-up can still execute.
  The new recovery view relies on a Room activity row that is not the wallet's durable record of the payment. In `wallet/shielded/operations.rs`, `record_pending_activity` queues the host row and logs persistence failures without stopping the spend; `save_spend_then_broadcast` separately saves the signed retry record before dispatch. If the host write fails, Rust can restore and retry a spend that this screen omits. Conversely, an exit after the row is persisted but before the retry record is saved can leave a pending row for a payment that was never sent. The shared write-boundary gap is tracked in dashpay/platform#6058, but this PR introduces the recovery UI that relies on that projection. Use wallet-owned recovery state or a wallet-reconciled projection, and treat unavailable recovery state as unknown. The cited test only creates a second handler over the same open in-memory database after inserting a synthetic row. Keep that query test, but set the manifest to `restart: required` and `covers_restart: false` until a test or recorded run reopens the relevant stores and verifies recovery at those write boundaries.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:217: Check Now can crash a transparent-only build when a pending row is retained
  Impact: A user who replaces a shielded build with the supported `--no-shielded` build while keeping app data can crash Top Up by tapping Check Now on a retained pending row.
  A Room row is enough to show this button, and a non-null manager enables it even when `Sdk.hasShielded()` is false. `WalletManagerNative.shieldedSyncNow` is exported only with the `shielded` feature, so the call throws `UnsatisfiedLinkError`, which the screen's `catch (Exception)` does not catch. Keep the persisted rows readable but gate the native action on the feature probe. The new `FfiSmokeTest.identityShieldAndShieldedTopUpSymbolsBindAndRejectInvalidInput` has the same missing gate: its four `FundingNative` exports are absent on this build, so use the `Sdk.hasShielded()` assumption already used in `ShieldedIdentityFlowsFfiTest`.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt`:
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt:245-253: Send can keep hiding a funded identity after its saved balance changes
  Impact: A user whose identity receives credits while Send is open can remain unable to select it, and a top-up result can keep showing the pre-payment balance after Room saves the new one.
  A balance update for an existing identity need not reach either payment view. `IdentityEntity.equals` compares only `identityId`, so a same-ID entity or list emitted by Room compares equal in the Compose state created by `collectAsStateWithLifecycle`. Send then retains the old list and filters on the old balance; Top Up likewise collects the entity directly and can label the stale value as the last saved balance even after Rust persists a newer proof-attested snapshot. The new result also converts a missing row to `0L`, although Type 22 returns an outcome, not a balance, through JNI. Project the DAO flows into UI values whose equality includes balance, keep missing balances nullable, and test a same-ID update without reopening the screens. Show cached balances as display data rather than using stale zero as the final authority on whether Rust may check a managed funding identity.
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt:789-809: Identity Send accepts an editable recipient that the wallet call cannot validate
  Impact: When a user enters a recipient for an identity-funded shield, only the ExampleApp's separate precheck ensures the entered destination agrees with the self-shield the wallet will build.
  The self-shield primitive correctly sends to the wallet's default address, but it never receives the destination that the Send form asks the user to approve. Kotlin fetches and compares the address in one call, then dispatches the no-recipient Type 21 operation in another; Swift has a separate copy of that payment restriction. The current comparison rejects a mismatch, but extending it to the new path leaves destination enforcement in the app instead of the wallet that constructs the payment. Present Type 21 as an explicit move to a read-only wallet destination, or pass an expected recipient through the binding and have `rs-platform-wallet` check it against the same account keys it uses to build the note. This does not require enabling third-party shielding on v5.1.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedIdentityFlows.kt`:
- [BLOCKING] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedIdentityFlows.kt:235-246: A valid one-credit top-up is reported as 0 DASH
  Impact: A user who submits the advertised minimum of 0.00000000001 DASH can spend a nonzero amount and a fee while the result and pending row report a zero-amount top-up.
  Both top-up outcomes misstate the amount the user requested. The parser accepts one credit and the form explicitly advertises it, but `formatCredits` converts through `Double` and renders at most eight fractional digits. The same formatter is used by the new pending top-up and identity-shield recovery rows. Format these amounts from exact credits at up to 11 decimal places and assert that a one-credit amount stays nonzero in the submitted, unconfirmed, and pending views.
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedIdentityFlows.kt:286-297: Check Now says the records are current even when the wallet was not checked
  Impact: A user checking an unresolved payment while offline or during another sync can be told that stale recovery records are current.
  Both Shielded Activity and Top Up set `Finished` after any normal return from `syncShieldedNow()`. The FFI discards the `ShieldedSyncPassSummary` and returns OK for a valid manager even when the pass lost the in-flight slot or the wallet's scan failed. The wallet's per-pass callback and rereading local records do not establish that this request successfully checked this wallet. Use neutral wording such as Swift's “Sync requested” without claiming the list is current, or carry a wallet-scoped outcome for the specific request across JNI before reporting completion.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:645-654: Existing Kotlin error handlers can break when they upgrade to the new code-58 subtype
  Impact: Consumers with an exhaustive `when` over `PlatformWallet` must add a branch to recompile, and handlers catching `PlatformWallet.Generic` no longer catch native code 58.
  The new mapping is correct, but it is not purely additive for Kotlin callers. `PlatformWallet` is public and sealed, and line 1026 changes code 58 from the fallback `Generic(58, ...)` to its sibling `IdentityBalanceUnavailable`. The PR describes the mapping but says there are no breaking changes. Document both the source-compatibility change and which branch callers should add for the refusal. No native ABI change is needed.

In `packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/ShieldedIdentityFlowsFfiTest.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/ShieldedIdentityFlowsFfiTest.kt:109-114: The empty-pool test passes without reaching note selection
  Impact: A green emulator run can be mistaken for coverage of the no-notes refusal even if the testnet protocol probe failed first.
  The test creates an unpinned Testnet SDK, and Rust runs `ensure_protocol_requirement` before reserving any notes. The test accepts any `DashSdkError` other than two unconfirmed variants, so a protocol-gate refusal also passes and leaves the activity table empty. The actual empty-pool branch returns `ShieldedNoUnspentNotes`, which `map_spend_result` currently flattens to the generic wallet-operation code; asserting that code alone is not enough either. Keep the default JNI smoke test deterministic and verify the no-notes refusal with a fixture that clears the protocol gate and distinguishes that refusal, or put the live-network assertion behind `TestnetGuard`.
Out-of-scope follow-up suggestions (2)

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.

  • A worker panic in the existing Type 21 export can abort the host — The existing Type 21 extern "C" call invokes block_on_worker, which panics if its worker panics. The outer JNI guard cannot recover an unwind that aborts at the inner C ABI boundary. Unlike Type 22, this shared export has no spend-panic guard.
    • Follow-up: Contain panics inside the Type 21 C export in a wallet FFI follow-up and preserve the unconfirmed outcome if the payment could have been dispatched.
  • An affected-state proof can confirm spent notes without identifying the exact top-up — On this head the existing Type 22 path can mark its activity confirmed if another device using the same seed spent the same inputs in a different transition. The proof authenticates the nullifiers and identity balance snapshot, not the exact transition; the PR does not change this proof contract.
    • Follow-up: Continue tracking transition-bound execution evidence in #4270.

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

…reen recreation in KotlinExampleApp

Review fixes for #6147:
- Run the type 21 and type 22 payments on an application-scoped
  coordinator, so a rotation or tab switch while they prove can neither
  drop the outcome nor start a second payment.
- Keep a selected Shielded Balance source selected (submission off) when
  its balance becomes unknown, instead of switching to Platform addresses.
- Project Room identities to plain values so balance and label updates
  recompose; a missing identity shows no balance rather than zero.
- Show amounts exactly at 11 decimals (one credit is not 0 DASH).
- Gate Check Now and the record read on shielded support.
- Check Now says a sync was requested, not that the list is current.
- Instrumented tests: smoke test assumes shielded support; the live test
  asserts the local not-found refusal only.
- Parity manifest: type 22 restart back to required (#6058).

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

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 23, 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 2 only (queue backlog)

Changes requested: 1 blocker

  • The emulator test fails when the wallet correctly refuses an unmanaged identity — packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/ShieldedIdentityFlowsFfiTest.kt:97 (new)
    Impact: On the shielded CI emulator, the assertion fails before the test can verify that the refused payment saved no recovery record or activity row.

New on this head: This revision moves both shielded identity payments into an application-scoped coordinator, preserves the selected funding source when the shielded balance is unavailable, and displays amounts at full credit precision. It also revises the JNI refusal test and the recovery coverage claims. The Kotlin SDK emulator job, JS build, and some Docker image builds were still pending at the CI check; no completed code check had failed.

🔴 1 blocking | 🟡 4 suggestion(s)

Review provenance

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

  • Triage: critical by gpt-6.2-sol (effort low) — SendTransactionScreen.kt and TopUpIdentityScreen.kt add real funds-movement paths whose dispatch, duplicate-submission prevention, and recovery depend on coordination across screen recreation and ambiguous outcomes.
  • Phase 1 reviewers: not run (skipped for throughput: 23 PRs queued, above the 10 limit)
  • New since the last final review (f2855602): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/ShieldedIdentityFlowsFfiTest.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/ShieldedIdentityFlowsFfiTest.kt:97: The emulator test fails when the wallet correctly refuses an unmanaged identity
  Impact: On the shielded CI emulator, the assertion fails before the test can verify that the refused payment saved no recovery record or activity row.
  The default Kotlin CI job builds with shielded support and runs `:sdk:connectedDebugAndroidTest`, which includes this test. The revised fixture creates a fresh wallet, binds account 0, and requests a positive shield from an identity the wallet does not manage. `shielded_shield_from_identity_impl` returns `IdentityNotFound` before any network call or payment write, but the Type 21 export sends that error through `map_spend_result`, whose fallback emits `ErrorWalletOperation` (6), not `ErrorIdentityNotFound` (7). JNI passes 1006 to Kotlin, which decodes it as `DashSdkError.PlatformWallet.WalletOperation`. Assert that subtype and the identity-specific diagnostic so unrelated code-6 failures cannot pass, and keep both no-write assertions.

  _Confirmed by an independent pass: The default Kotlin emulator CI job builds with shielded support and runs `:sdk:connectedDebugAndroidTest`, where the new test requests a 1,000-credit shield from an unmanaged identity in a freshly created wallet with shielded account 0 bound. The wallet correctly refuses the request before any network call or payment write, but the test receives `DashSdkError.PlatformWallet.WalletOperation` rather than `DashSdkError.NotFound`, so line 97 fails the job before either no-write assertion runs._

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/services/shielded/ShieldedIdentityPaymentCoordinator.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/services/shielded/ShieldedIdentityPaymentCoordinator.kt:51-60: Concurrent starts can both launch a payment for the same slot
  Impact: If two callers invoke `start` concurrently for the same key, both payment callbacks can run even though the coordinator records only one reservation.
  The new coordinator can launch a payment without reserving its slot. `MutableStateFlow.update` retries its lambda after a failed compare-and-set: both callers can first see an empty slot and set their local `started` flag, then the losing caller sees the winner's entry on retry but never clears that flag. Both current screen callers run on Main, so this is not a remaining rotation or tab-switch failure. Make dispatch conditional on the successful compare-and-set.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/credits/TopUpIdentityScreen.kt:278-281: Leaving a top-up result with Back shows the same result on the next visit
  Impact: A user who reads the result and leaves with system Back or the toolbar arrow must dismiss it and reopen Top Up before entering a new payment for that identity.
  The retained result replaces the form again on the next visit because only Done acknowledges the coordinator entry. Once the payment finishes, `isBusy` is false, so both Back routes can pop the screen without clearing it. Route explicit Back navigation from the displayed result through the same acknowledge-and-pop action as Done. Keep the result on composition disposal so rotation and tab switches still preserve it.

In `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedActivityScreen.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/shielded/ShieldedActivityScreen.kt:106-110: Shielded Activity can say there is no activity when recovery records cannot be read
  Impact: If a transparent-only build restores Shielded Activity with retained wallet data and no Room activity rows, the user can see “No shielded activity” even though the recovery store was never checked.
  The new guard correctly avoids the missing JNI export, but `applySuccess(emptyList())` marks the recovery records as known empty and enables the empty-state message. `Sdk.hasShielded()` reports a build capability, not what a previous build saved. The normal Wallet Detail entry is hidden in this configuration, but the navigation destination is still registered. Keep the guard and use the existing unreadable state.

In `docs/sdk/sdk-parity-manifest.json`:
- [SUGGESTION] docs/sdk/sdk-parity-manifest.json:3562-3568: The parity manifest credits a test that no longer calls the top-up binding
  Impact: Readers checking Type 22 device coverage are directed to a test that does not invoke `shieldedIdentityTopUpFromPool`.
  The Type 22 verification list and Kotlin coverage reason still credit the renamed test with binding the top-up export. This revision removed that call: the test estimates the Type 22 fee, but its only payment call is a Type 21 shield. Keep `FfiSmokeTest` as evidence for invoking the Type 22 export, and either remove the renamed test from that entry or describe it strictly as fee-estimation coverage.

Comment thread docs/sdk/sdk-parity-manifest.json Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 23, 2026
…hten the payment coordinator

- ShieldedIdentityFlowsFfiTest: the shield export reports IdentityNotFound
  as WalletOperation (code 6) naming the identity; assert that.
- Coordinator: launch only after this caller's compare-and-set reserved
  the slot.
- Top Up: leaving a shown result with Back or the toolbar arrow
  acknowledges it, as Done does.
- Shielded Activity: without shielded support the records are
  unreadable, not known empty.
- Parity manifest: the type 22 entry no longer credits a test that does
  not call the top-up export.

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

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 23, 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 2 only (queue backlog)

New on this head: This revision reserves each payment slot atomically before dispatch, acknowledges displayed top-up results on Back, and treats recovery records as unreadable in builds without shielded support. It also corrects the unmanaged-identity test assertion and the Type 22 parity manifest’s test attribution. No code checks have failed on this head; the Kotlin x86_64 emulator job is queued, and the JS and Dashmate helper builds are pending.

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

Review provenance

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

  • Triage: critical by gpt-6.2-sol (effort low) — SendTransactionScreen.kt and TopUpIdentityScreen.kt add dispatch paths that move real credits, while ShieldedIdentityPaymentCoordinator.kt and the recovery UI govern when an in-flight or ambiguously submitted payment can be attempted again.
  • Phase 1 reviewers: not run (skipped for throughput: 18 PRs queued, above the 10 limit)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added the waiting-self-review Waiting for the author to post /self-reviewed label Nov 23, 2026
@github-actions github-actions Bot removed the waiting-bots Waiting for the review bots to report on this head label Nov 23, 2026
…le-identity-shield-and-shielded-top-up

# Conflicts:
#	docs/sdk/sdk-parity-manifest.json
#	packages/kotlin-sdk/KotlinExampleApp/TEST_PLAN.md
#	packages/kotlin-sdk/PARITY_SUMMARY.md
#	packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/FfiSmokeTest.kt
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 23, 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

New on this head: This head merges v5.1-dev, combining the key-limit and shielded-payment test coverage without changing the Kotlin identity-shield or shielded top-up screens. No code checks have failed on this head; the Kotlin SDK x86_64 emulator job is still pending. Funded payments, rotation and tab switching during proof generation, and process-death recovery have not been verified on a device.

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

Review provenance

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

  • Triage: critical by gpt-6.2-sol (effort low) — SendTransactionScreen.kt and TopUpIdentityScreen.kt add dispatch paths that move funds, and ShieldedIdentityPaymentCoordinator.kt adds lifecycle-spanning deduplication whose correctness matters to preventing duplicate payments.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

…le-identity-shield-and-shielded-top-up

# Conflicts:
#	packages/kotlin-sdk/PARITY_SUMMARY.md
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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

@QuantumExplorer
QuantumExplorer merged commit 923b47d into v5.1-dev Nov 23, 2026
20 of 22 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/kotlin-example-identity-shield-and-shielded-top-up branch November 23, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-bots Waiting for the review bots to report on this head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants