Registry Mirror
Skip to content

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: KotlinExampleApp's Direct Purchase screen can now pay from the wallet's shielded balance instead of the identity's credits, using TokenPurchaseFromShieldedPool (state transition type 28). This is the Android side of what SwiftExampleApp got in #6090. The wallet's shielded notes pay the price and a fee; the tokens are minted as a note to the wallet's own address in the token's shielded pool. No identity is involved.

Before: the form's only option was to debit the identity's credits.
After: when Rust reports that the token has a shielded pool, a Pay with control offers Identity credits (unchanged) or Shielded pool. The shielded option shows the shielded balance, the pool fee estimate and price plus fee. A purchase that Platform accepts is reported as submitted, and a shielded sync confirms it once it lands.

Risks: Low. No Rust wallet, FFI, Drive or DPP change: the Rust side from #6090 is used as it is, through two new JNI exports that only marshal. The identity-credit purchase path is unchanged apart from its Buy button's test tag (see Public interface changes).

Before: Token, Amount, Total cost, [Buy]
After:  Token
        Pay with: [Identity credits | Shielded pool]      (only when Rust says the token has a pool)
        Amount, Total cost
        Shielded pool                                      (when Shielded pool is chosen)
          Shielded balance        99835631000 credits
          Pool fee (estimate)     <Rust's estimate> credits
          Price + fee             <total> credits
          The purchased tokens go to this wallet's shielded token pool. The app does not show
          shielded token balances yet ...
        [Buy] -> "Purchase submitted. Platform accepted it; a shielded sync confirms it once
                  it lands ... Do not retry."

A token without a shielded pool:
        Pay with: Identity credits
        This token has no shielded pool, so it can't be bought from the shielded pool.

The figures illustrate the layout; they are not from a run.

Not yet verified

  • The flow in the app on an emulator (TEST_PLAN SH-24), including a real purchase that Drive accepts. It needs a token with a direct purchase price and a shielded pool on a network at protocol version 14 or later, plus an identity and a shielded balance in the app; none was set up for this PR. The Swift flow (feat(swift-example-app): buy a token from the shielded pool (type 28) #6090) has not been run on a device either. The parity manifest therefore keeps Kotlin at partial with restart required.
  • A process kill while a purchase is Pending. Only the unit test that a pending purchase row is restored by a new handler over the same database covers it.
  • The x86_64 native library was not built; only arm64.
  • Back being blocked during a purchase, on an emulator: it needs the same token setup as the flow above. The change follows the pattern DecisionProposalsScreen already uses.

Issue being fixed or feature implemented

docs/sdk/sdk-parity-manifest.json listed shielded.token_purchase_from_pool as unsupported for both the Kotlin SDK and KotlinExampleApp: "No JNI wrapper or KotlinExampleApp flow for the shielded token purchase yet." Swift reference: #6090 (TEST_PLAN SH-24).

No open PR or issue covers the Kotlin side.

What was done?

Every conclusion of #6090's review carries over, because the decisions live in the Rust code this calls and Kotlin adds none of its own:

  • Submitted, not confirmed. Type 28's result proof is only the token pool's balance, which binds neither the fee nullifiers nor the minted note. Rust returns ShieldedTokenPurchaseOutcome::Submitted and keeps the purchase pending until the credit pool scan finds the fee bundle's change note. Kotlin shows exactly that: the dialog says submitted, the activity row stays Pending, and the row says the tokens were minted only once its stored status is Confirmed.
  • No failure is inferred. Nothing in JNI or Kotlin marks a pending purchase failed from what a scan did or did not see. A pending purchase whose notes another device spends first stays pending (platform-wallet: a pending shielded spend never resolves once another spend consumes its inputs #6108); the scan watermark gap is platform-wallet: a shielded note scan advances its watermark past a gap between fetched ranges #6109. Neither is touched here.
  • Availability is Rust's answer. The form offers the shielded payment only when shieldedTokenPurchaseAvailability returns available. No shielded pool and configuration unreadable are shown apart, the second with Retry.
  • Whether the notes cover price plus fee is Rust's refusal. The form requires only a known, non-zero shielded balance before enabling Buy, as the send screen's shielded flows do.
  • The follow-up sync is requested by the Rust manager, not by JNI or Kotlin.

rs-unified-sdk-jni

  • New shielded_token_purchase.rs with two exports, each one call into platform-wallet-ffi.

kotlin-sdk

  • PlatformWalletManager.shieldedTokenPurchaseFromPool(...) and shieldedTokenPurchaseAvailability(...), ShieldedTokenPurchaseAvailability, and ShieldedProver.FeeKind.TokenPurchaseFromPool (fee kind 5).

KotlinExampleApp

  • PurchaseForm (TokenActionScreens.kt) gains the Pay with choice, the shielded section and the shielded submit; the new pieces are in ShieldedTokenPurchase.kt.
  • The outcome message is held in TokenActionViewModel, so it survives a rotation and the form closes only when it is dismissed.
  • Shielded Activity labels kind tag 10 "Token Purchase" and adds a line under its status that depends on the stored status.
  • The Swift accessibility identifiers are reused as test tags: tokenPurchase.fundingSource, tokenPurchase.buyButton, tokenPurchase.shieldedBalance, tokenPurchase.shieldedTokensNote, tokenPurchase.shieldedUnavailable.

Docs: Kotlin TEST_PLAN.md rows SH-24 (mirrors Swift SH-24) and SH-25 (mirrors Swift SH-25: shielded token balances, not implemented); the manifest entry and regenerated PARITY_SUMMARY.md.

Not included: showing or spending the bought tokens. The wallet syncs only the credit shielded pool, so the tokens are on chain but not shown, and the form and the test plan say so. Token pool note sync is being built separately. Types 26 and 27 are not ported, as on iOS.

Public interface changes

JNI: org.dashfoundation.dashsdk.ffi.ShieldedTokenPurchaseNative (new, internal)

Export Bridges
purchaseFromPool(managerHandle, walletId, resolverHandle, account, dataContractId, tokenPosition, tokenCount, totalAgreedPrice) platform_wallet_manager_shielded_token_purchase_from_pool. Returning means submitted. Throws as the other note-spending exports do.
availability(managerHandle, dataContractId, tokenPosition): Int platform_wallet_manager_shielded_token_purchase_availability: 0 available, 1 no shielded pool, 2 configuration unreadable. Throws when the question could not be asked.

tokenCount and totalAgreedPrice are unsigned 64-bit values passed as their two's-complement Long. A wallet or contract id that is not 32 bytes, a negative account and a token position outside 0 to 65535 are refused before any wallet code runs. No callback slot is added.

Kotlin API

  • suspend fun PlatformWalletManager.shieldedTokenPurchaseFromPool(walletId, contractId, tokenPosition, tokenCount: ULong, totalAgreedPrice: ULong, account = 0). Returns when Platform accepted the purchase, which means submitted, not confirmed. Throws DashSdkError.PlatformWallet.ShieldedSpendUnconfirmed once the purchase may have reached a node (do not retry); every other error means nothing was sent.
  • suspend fun PlatformWalletManager.shieldedTokenPurchaseAvailability(contractId, tokenPosition): ShieldedTokenPurchaseAvailability.
  • Both refuse a tokenPosition outside 0..65535 with an IllegalArgumentException before the native call, as Tokens does.
  • enum class ShieldedTokenPurchaseAvailability { Available, NoShieldedPool, ConfigurationUnreadable }. A byte this build does not know is read as ConfigurationUnreadable, never as Available.
  • ShieldedProver.FeeKind.TokenPurchaseFromPool (raw 5) for estimateShieldedFee.

KotlinExampleApp

  • TokenActionScaffold gains submitTestTag: String = "tokenAction.submitButton". The Direct Purchase form passes tokenPurchase.buyButton, Swift's identifier, for both funding sources, so the Buy button's test tag on that one form changes from tokenAction.submitButton. Every other token action keeps the old tag.
  • TokenActionViewModel gains notice, showNoticeUntilDismissed(message) and dismissNotice().
  • TokenActionScaffold gains backBlocked: Boolean = false, which blocks system Back and disables the toolbar Back. The Direct Purchase form sets it while a purchase is being submitted and until its outcome message is dismissed, for both funding sources: leaving would clear the view model that shows the "submitted, do not buy again" message. Every other token action is unchanged.

Room

No table, column or version change. A token purchase is a shielded_activities row with kindTag = 10 and the token's id as counterparty, both of which the existing columns and callbacks already carry.

How Has This Been Tested?

  • cargo fmt --all: clean.
  • cargo clippy -p rs-unified-sdk-jni --all-targets --all-features --locked -- --no-deps -D warnings: clean.
  • cargo test -p rs-unified-sdk-jni --all-features --lib: 86 passed.
  • ./gradlew :sdk:testDebugUnitTest for ShieldedTokenPurchaseAvailabilityTest (3), ShieldedTokenPurchaseActivityPersistenceTest (2) and PlatformWalletPersistenceHandlerTest: all passed. They cover each availability byte, an unknown byte never reading as available, fee kind 5, a pending purchase row (kind 10, token id as counterparty, change note and reserved nullifiers) restored by a new handler over the same database, and a later status replacing that row.
  • ./gradlew :app:testDebugUnitTest for ShieldedTokenPurchaseTest (8) and TokenDirectPurchasePricingTest (17): all passed. They cover the shielded payment offered only on Rust's available answer, the reason shown for each other answer and when Retry is offered, when Buy is enabled, an accepted purchase reported as submitted and never as complete, a purchase that may have reached a node reported without a retry, an error that sent nothing passed on to the error dialog, and the activity row saying the tokens were minted only when Confirmed.
  • ./build_android.sh --abi arm64: built; the library exports the two ShieldedTokenPurchaseNative symbols.
  • Instrumented tests on an emulator (API 35, arm64), ./gradlew :sdk:connectedDebugAndroidTest filtered to FfiSmokeTest and ShieldedTokenPurchaseFfiTest: 14 of 14 passed, re-run on the review commit with a rebuilt library. The new ones show that both exports bind, that an invalid manager handle throws the mapped error, that arguments of the wrong size or range are refused before any wallet code runs, and, through a real manager and an unfunded wallet, that the fee estimate for kind 5 is a positive number, both wrappers refuse a token position of -1 or 65536 with an IllegalArgumentException, and a purchase of zero tokens is refused as "nothing sent" (not as a spend that may have gone through) with no activity row left behind.
  • python3 scripts/check_sdk_parity_manifest.py --write-summary: OK.

See "Not yet verified" for what has not run.

Breaking Changes

None. No protocol, consensus, C ABI, Room or persisted-format change. The one visible change is the Direct Purchase form's Buy button test tag (see Public interface changes).

Checklist:

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 5a34be9

  • 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/ui/shielded/ShieldedActivityScreen.kt, packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/tokens/ShieldedTokenPurchase.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.

Ports the shielded token purchase from SwiftExampleApp (#6090) to the
Kotlin SDK and KotlinExampleApp.

- rs-unified-sdk-jni: ShieldedTokenPurchaseNative exports for the purchase
  and for whether a token can be bought that way, each one call into
  platform-wallet-ffi.
- kotlin-sdk: PlatformWalletManager.shieldedTokenPurchaseFromPool and
  shieldedTokenPurchaseAvailability, ShieldedTokenPurchaseAvailability and
  ShieldedProver.FeeKind.TokenPurchaseFromPool (fee kind 5).
- KotlinExampleApp: the Direct Purchase form offers "Pay with: Shielded
  pool" only on Rust's availability answer, reports an accepted purchase as
  submitted (a shielded sync confirms it once it lands), and Shielded
  Activity lists the Token Purchase row, saying the tokens were minted only
  once it is Confirmed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@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 19 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 b31c4d4 and a149ef8.

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/ui/shielded/ShieldedActivityScreen.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/tokens/ShieldedTokenPurchase.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/tokens/TokenActionScaffold.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/tokens/TokenActionScreens.kt
  • packages/kotlin-sdk/KotlinExampleApp/app/src/test/java/org/dashfoundation/example/ui/tokens/ShieldedTokenPurchaseTest.kt
  • packages/kotlin-sdk/PARITY_SUMMARY.md
  • packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/ShieldedTokenPurchaseFfiTest.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/FundingNative.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/ShieldedTokenPurchaseNative.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/funding/ShieldedProver.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/ShieldedTokenPurchaseAvailability.kt
  • packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/persistence/ShieldedTokenPurchaseActivityPersistenceTest.kt
  • packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/wallet/ShieldedTokenPurchaseAvailabilityTest.kt
  • packages/rs-unified-sdk-jni/src/funding.rs
  • packages/rs-unified-sdk-jni/src/lib.rs
  • packages/rs-unified-sdk-jni/src/shielded_token_purchase.rs
  • 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 added this to the v5.1.0 milestone Nov 23, 2026
@QuantumExplorer
QuantumExplorer marked this pull request as ready for review November 23, 2026 09:05
@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 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

🔍 Review in progress (commit a149ef8) · live progress

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

⚠️ DEGRADED — Final validation — Phase 1 + Phase 2

⚠️ DEGRADED review. The primary review models were unavailable (gpt-6.2-sol unavailable: Request rejected (429) · All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The us), so this review ran on stand-in models: gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped at high effort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.

Nothing blocks: no blocking finding stands on this head.

Kotlin parity port of Swift #6090 for Type 28 shielded token purchases via two marshal-only JNI exports, thin Kotlin wrappers, and a Direct Purchase Pay-with flow. CI is still running (Kotlin SDK build + tests and Rust workspace tests in progress) with no failed checks reported on this head.

🟡 2 suggestion(s) | 💬 1 nitpick(s)

Review provenance

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

  • Degraded mode: gpt-6.2-sol unavailable: Request rejected (429) · All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The us (detected by probe, since 2026-11-23T09:07:27Z); stand-ins gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor; Phase 1 effort capped at high
  • Triage: normal by muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (effort low) — Adds a new Kotlin UI purchase path plus JNI marshaling wrappers with tests, a cross-cutting but non-consensus change reusing existing Rust logic.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (zai below 15% reserve: 5h 100% left, weekly 0% left)
  • 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: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — final-verifier; agent sol-verifier
  • Phase 2 reviewers: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — general (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — architecture-layering (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — ffi-engineer (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — general (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — architecture-layering (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — ffi-engineer (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/tokens/TokenActionScreens.kt`:
- [SUGGESTION] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/tokens/TokenActionScreens.kt:861-934: Backing out during the minute-long shielded proof discards the submitted / do-not-retry notice
  Impact: A buyer who presses back while the shielded purchase is proving never sees the submitted dialog and may pay for the same tokens twice.
  The consequence is a lost safety-critical instruction, not just a lost spinner. The shielded purchase proves for a minute or more, and the whole do-not-retry contract depends on the notice dialog held in TokenActionViewModel and shown after the blocking call returns. Nothing blocks removal while viewModel.isSubmitting: TokenActionScaffold's top-app-bar back button at TokenActionScaffold.kt pops unconditionally and there is no BackHandler in PurchaseForm. On pop the entry-scoped ViewModel is cleared (documented in TokenActionScaffold.kt), so when the blocking FFI call returns the notice/completed state lands on a discarded ViewModel and the buyer never learns the purchase was submitted and must not be retried. Re-entering the form and buying again is then one deliberate tap away. Follow the existing DecisionProposalsScreen/MultipleChoiceProposalsScreen pattern: block system back while submitting and disable the toolbar back for the same reason.
- [NITPICK] packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/tokens/TokenActionScreens.kt:725-756: Funding choice persisted as an enum ordinal breaks if the enum is reordered
  Impact: If PurchaseFundingSource ever gains or reorders entries, a saved ordinal from a rotated or restored form could reselect the wrong funding source or crash on entries[fundingOrdinal].
  The consequence is only a wrong preselected Pay-with option (or an out-of-bounds crash) after process recreation plus an app update. fundingOrdinal stores PurchaseFundingSource.ordinal via rememberSaveable and restores with entries[fundingOrdinal] with no bounds check, only a takeIf fallback for disallowed sources. Persist the name (or a boolean isShielded) instead of the ordinal.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:2324-2375: Token position outside 0..65535 reaches JNI instead of failing fast in Kotlin
  Impact: A caller passing a negative or >65535 tokenPosition to the new shielded purchase wrappers gets a native DashSDKException instead of the IllegalArgumentException every other token entry point raises.
  The consequence is an inconsistent error surface for the same bad input. Tokens.kt centralizes this in validateSelectors (0..0xFFFF), and the new JNI layer re-validates with u16::try_from via read_token_position, so the value is safe but the failure mode differs: shieldedTokenPurchaseFromPool and shieldedTokenPurchaseAvailability check account and 32-byte ids with require but have no tokenPosition require, leaving the u16 range enforced only across the JNI boundary. Add the same require to both wrappers before mapNativeErrors.

@github-actions

Copy link
Copy Markdown
Contributor

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

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

Review of the shielded token purchase port.

- The purchase form blocks system Back and disables the toolbar Back while
  a purchase is being submitted. Leaving popped the entry and cleared its
  view model, so the message a shielded purchase ends with (submitted, do
  not buy again) was never shown.
- The funding choice is saved as the enum value, not its ordinal.
- `shieldedTokenPurchaseFromPool` and `shieldedTokenPurchaseAvailability`
  refuse a token position outside 0..65535 before the native call, with
  the error `Tokens` raises for it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@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.

⚠️ DEGRADED — Re-review — Final validation — Phase 1 + Phase 2

⚠️ DEGRADED review. The primary review models were unavailable (gpt-6.2-sol unavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache), so this review ran on stand-in models: gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor. Both review phases and the independent verifiers still ran, but on weaker models, with Phase 1 capped at high effort. Treat the verdict as provisional; a full-strength re-review will run on the next push once the primary models are back.

Nothing blocks: no blocking finding stands on this head.

New on this head: Head bee8363 keeps the Direct Purchase form open until its submitted/do-not-retry notice is dismissed and adds fail-fast token-position checks. Kotlin SDK build plus x86_64 emulator tests pass; Rust workspace tests are still pending with no failure attributed to this change.

💬 2 nitpick(s)

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

💬 Nitpick: Activity entity KDoc still lists kind tags 0-9 after kind 10 was added
Impact: A reader of the persistence entity misses that a shielded token purchase is stored as kindTag 10 with the token id as counterparty.
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/ShieldedActivityEntity.kt:29-33

The consequence is stale documentation only. The KDoc enumerates tags 0-9, but this change stores token purchases as kindTag 10 (Rust ShieldedActivityKind::TokenPurchase, matched by KIND_TOKEN_PURCHASE = 10 in the activity screen), with the token id as counterparty. Update the comment to name tag 10.

    /**
     * `ShieldedActivityKind::tag`: 0 Shield, 1 ShieldFromAssetLock,
     * 2 Received, 3 Sent, 4 Unshield, 5 Withdrawal, 6 IdentityCreate,
     * 7 ShieldedSpend, 8 ShieldFromIdentity, 9 IdentityTopUpFromPool,
     * 10 TokenPurchase.
     */

source: muse-spark-1.3-contributor (phase2-reviewer: general)

Review provenance

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

  • Degraded mode: gpt-6.2-sol unavailable: All credentials for model gpt-6.2-sol are cooling down (last error: usage_limit_reached: The usage limit has been reache (detected by probe, since 2026-11-23T09:07:27Z); stand-ins gpt-5.6-luna → muse-spark-1.3-contributor, gpt-5.6-sol → muse-spark-1.3-contributor, gpt-5.6-terra → muse-spark-1.3-contributor, gpt-6-astra → muse-spark-1.3-contributor, gpt-6.1-sol → muse-spark-1.3-contributor, gpt-6.2-astra → muse-spark-1.3-contributor, gpt-6.2-sol → muse-spark-1.3-contributor; Phase 1 effort capped at high
  • Triage: normal by muse-spark-1.3-contributor (standing in for gpt-6.2-sol) (effort low) — Large UI plus JNI wiring change that reuses existing Rust purchase logic without changing consensus, crypto, or funds-selection rules itself.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (zai below 15% reserve: 5h 100% left, weekly 0% left)
  • 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: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — final-verifier; agent sol-verifier
  • Phase 2 reviewers: muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — general (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — architecture-layering (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — ffi-engineer (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — general (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — architecture-layering (completed, effort high); agent phase2-reviewer, muse-spark-1.3-contributor (standing in for gpt-6.2-sol) — ffi-engineer (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/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/ShieldedActivityEntity.kt`:
- [NITPICK] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/persistence/entities/ShieldedActivityEntity.kt:29-33: Activity entity KDoc still lists kind tags 0-9 after kind 10 was added
  Impact: A reader of the persistence entity misses that a shielded token purchase is stored as kindTag 10 with the token id as counterparty.
  The consequence is stale documentation only. The KDoc enumerates tags 0-9, but this change stores token purchases as kindTag 10 (Rust ShieldedActivityKind::TokenPurchase, matched by KIND_TOKEN_PURCHASE = 10 in the activity screen), with the token id as counterparty. Update the comment to name tag 10.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt`:
- [NITPICK] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:2310-2313: Purchase KDoc names only one of the do-not-retry errors
  Impact: A caller reading only the purchase KDoc could retry on TransactionBroadcastUnconfirmed or StateTransitionResultUnconfirmed, which also mean the purchase may have reached a node.
  The consequence is a misleading retry contract in docs only. The KDoc says ShieldedSpendUnconfirmed means do-not-retry and every other error means nothing was sent, but the example app correctly treats TransactionBroadcastUnconfirmed and StateTransitionResultUnconfirmed the same way through shieldedOperationMayHaveGoneThrough, and the FFI test distinguishes a zero-count refusal from either unconfirmed error. Broaden the KDoc to name all three may-have-gone-through errors.

…ase caller must not retry on

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@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.

…le-shielded-token-purchase

Conflicts: the read-only tag list in the Kotlin TEST_PLAN.md keeps both
DOC-17 and SH-25; PARITY_SUMMARY.md is regenerated from the merged manifest.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@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.

QuantumExplorer and others added 3 commits November 23, 2026 18:01
…le-shielded-token-purchase

Conflicts: the tier counts of the Kotlin TEST_PLAN.md add both sides' rows
(SH-24 here, DPNS-09..13 from the base); PARITY_SUMMARY.md is regenerated
from the merged manifest.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…le-shielded-token-purchase

Conflicts: the read-only tag list of the Kotlin TEST_PLAN.md keeps both
sides' rows (SH-25 here, ADDR-10 and ADDR-11 from the base), and
PARITY_SUMMARY.md is regenerated from the merged manifest. Both sides had
raised the Common tier count from 29 to 30 for a different row, which
merged as one change; it is 31.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…le-shielded-token-purchase

Conflicts: an import beside the identity removal one in
PlatformWalletManager.kt (both kept); the tag lists of the Kotlin
TEST_PLAN.md keep both sides' rows (SH-25 here, ID-18 from the base);
PARITY_SUMMARY.md is regenerated from the merged manifest.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@QuantumExplorer
QuantumExplorer merged commit c562b1a into v5.1-dev Nov 23, 2026
7 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/kotlin-example-shielded-token-purchase branch November 23, 2026 11:11
QuantumExplorer added a commit that referenced this pull request Nov 23, 2026
…le-shielded-max-drain

Conflicts with the shielded token purchase port (#6131) in the Kotlin
TEST_PLAN.md: both sides' rows are kept (SH-18..20 here, SH-24 and SH-25
from the base) and the counts add both. Both sides had raised the Common
tier count from 30 to 31 for a different row, which merged as one change;
it is 32. PARITY_SUMMARY.md is regenerated from the merged manifest.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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