Skip to content

feat(kotlin-sdk): shield from identity to a third-party Orchard address - #5896

Open
HashEngineering wants to merge 2 commits into
v5.2-devfrom
feat/kotlin-sdk-identity-to-shielded
Open

HashEngineering wants to merge 2 commits into
v5.2-devfrom
feat/kotlin-sdk-identity-to-shielded

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

The Android Dash wallet's External Send (MO-1121) needs to shield credits from an identity's balance to someone else's Orchard address. shieldedShieldFromIdentity always targets the wallet's own address.

The Rust wallet method PlatformWallet::shielded_shield_from_identity_to_recipient already exists. This PR adds its FFI export, JNI bridge and Kotlin binding.

Builds on #5873 (Kotlin shieldedShieldToRecipient, merged into v5.2-dev); this PR is rebased onto v5.2-dev after that merge.

Overlap with #5863 (Swift shieldedShieldFromIdentityToRecipient): both PRs add the FFI export platform_wallet_manager_shielded_shield_from_identity_to_recipient with the same nine-parameter signature (agreed on #5863). Whichever merges second must drop its copy of the export and keep the other. #5863's copy also checks the identity's proved balance before arming the debit guard, so if #5863 lands first, this PR drops its FFI export and keeps only the JNI and Kotlin layers.

What was done?

  • FFI: new export platform_wallet_manager_shielded_shield_from_identity_to_recipient in rs-platform-wallet-ffi/src/shielded_send.rs. It follows the shield_to_recipient export:

    • the body runs inside catch_spend_panic, so a panic comes back as ErrorShieldedSpendUnconfirmed (18) instead of aborting the host;
    • the memo is decoded through encode_memo_text before the wallet is resolved;
    • out_new_balance (nullable) is written only on success;
    • errors go through map_spend_result, which keeps ErrorShieldedIdentityDebitPending (55) distinct from 18.

    The identity-debit guard in rs-platform-wallet is unchanged.

  • JNI: new export FundingNative.shieldedShieldFromIdentityToRecipient in rs-unified-sdk-jni/src/funding.rs, which returns the identity's balance after the debit. It reuses read_id32, read_recipient43 and read_cstring_opt, and rejects only what marshalling requires: negative values (before the unsigned cast), a null signer handle, and mis-sized ids.

  • Kotlin: new PlatformWalletManager.shieldedShieldFromIdentityToRecipient(walletId, identityId, recipientRaw43, amount, shieldedAccount = 0, memo = null): Long. It maps errors through mapNativeErrors and signs with the identity signer, as shieldedShieldFromIdentity does. It runs in teardownGate.opReturningCompletedResult (feat(kotlin-sdk): partial-amount platform-address withdrawal #5830), as shieldedShieldToRecipient (feat(kotlin-sdk): bind Platform → third-party Orchard shield (shieldedShieldToRecipient) #5873) does. Its KDoc states that:

    • Rust rejects a recipient the account's own IVK recognizes, so self-shields use shieldedShieldFromIdentity;
    • the memo may be at most 32 UTF-8 bytes;
    • the caller must not retry on ShieldedSpendUnconfirmed or ShieldedIdentityDebitPending, because a retry could debit the identity twice;
    • if the caller is cancelled after the native call has completed, the post-debit balance is still returned, so a completed identity debit is never hidden behind a CancellationException.
  • Validation lives once: following the book, the zero-amount check, the memo rules and the own-address rejection stay in Rust. Kotlin and JNI only marshal.

  • PARITY.md notes the binding as SDK only on the SendTransactionView row. Swift has no identity-to-recipient API; the SDK parity manifest doesn't list the shield FFIs, so it and PARITY_SUMMARY.md are unchanged.

How Has This Been Tested?

  • cargo fmt on the touched files, and cargo clippy --all-targets -D warnings on platform-wallet-ffi (with shielded) and rs-unified-sdk-jni.
  • cargo test -p platform-wallet-ffi --features shielded shielded_send (33 passed), including three new tests:
    • each required pointer null → ErrorNullPointer;
    • an over-limit memo and an invalid UTF-8 memo rejected before the wallet is resolved;
    • an unknown manager handle → ErrorInvalidHandle, with out_new_balance left untouched.
  • cargo test -p rs-unified-sdk-jni (72 passed) and ./gradlew :sdk:testDebugUnitTest.
  • New instrumented ShieldFromIdentityToRecipientBindingTest, which needs no wallet, network or funds. It passed 6/6 on an x86_64 API 36 emulator against a libdash_sdk_jni.so freshly built from 0bc049d620, this PR's head before the rebase onto v5.2-dev (run together with feat(kotlin-sdk): bind Platform → third-party Orchard shield (shieldedShieldToRecipient) #5873's ShieldToRecipientBindingTest: 13/13 in all). The rebase left this PR's diff unchanged; the emulator run was not repeated on the new base. It pins:
    • the JNI symbol and descriptor;
    • each JNI boundary rejection (raw code 1, with a message naming the argument, which also pins the order of the two 32-byte ids);
    • a zero amount and well-formed calls reaching the FFI's invalid-handle path;
    • an over-limit memo being rejected by Rust's encode_memo_text.

Breaking Changes

None. The change only adds code.

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 · e8b644b

  • Bots — thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Build failed
  • Approvals
    • kotlin-sdk — you own it
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/src/shielded_send.rs) — ZocoLini or llbartekll or romchornyi
    • files with no dedicated owner (packages/rs-unified-sdk-jni/src/funding.rs) — QuantumExplorer or shumkov

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.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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
  • 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

@thepastaclaw

thepastaclaw commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

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

@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

The added identity-to-third-party shield path is correctly layered across Kotlin, JNI, Rust FFI, and the existing wallet implementation. Static verification found no in-scope correctness, security, lifecycle, ownership, or API issues, and the changed-code CI check passed; only the review check remains in progress.

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: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: 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) — The diff is a substantial cross-language change to a funds-movement path that debits an identity and performs shielded sending, including signing and FFI/JNI boundary handling.
  • 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 quota lookup 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.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 — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
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.

  • Guard the older identity shield exports against proving-task panics — The pre-existing platform_wallet_manager_shielded_shield and platform_wallet_manager_shielded_shield_from_identity exports call block_on_worker without catch_spend_panic. Since block_on_worker re-panics when its proving task panics, an unwind can abort the host at the extern "C" boundary instead of returning the ambiguous-spend error. The new export correctly uses the guarded pattern, so this is an adjacent pre-existing issue rather than a defect introduced by this PR.
    • Follow-up: Open a focused follow-up PR that wraps both older shield exports in catch_spend_panic and adds panic-to-ErrorShieldedSpendUnconfirmed coverage matching the existing guard tests.

@HashEngineering
HashEngineering force-pushed the feat/kotlin-sdk-shield-to-recipient branch from fbeb778 to bc2a892 Compare November 13, 2026 06:36
romchornyi added a commit that referenced this pull request Nov 13, 2026
…s to a recipient

platform_wallet_manager_shielded_shield_from_identity_to_recipient now takes
an optional memo_text between amount and signer_identity_handle (9 parameters),
matching the shape PR #5896 exports for the Kotlin/JNI binding. NULL or empty
means no memo; otherwise the text is encoded with encode_memo_text (over 32
UTF-8 bytes is ErrorInvalidParameter, invalid UTF-8 is ErrorUtf8Conversion),
before the wallet handle is resolved and after the pointer checks.

Swift: shieldedShieldFromIdentityToRecipient gains memo: String? = nil, passed
with withCString or nil like shieldedShieldToRecipient.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HashEngineering
HashEngineering force-pushed the feat/kotlin-sdk-identity-to-shielded branch from 8b08328 to 0bc049d Compare November 13, 2026 07:16

@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 new identity-to-recipient binding is correctly layered and preserves the native error, signer, balance, and cancellation contracts. Three non-blocking issues remain: the existing self-shield Kotlin method still uses the cancellation-vulnerable gate, the new FFI export duplicates unsafe memo decoding, and ambiguous identity shields do not trigger the immediate recovery sync used by other shielded spends. CI shows the Kotlin build/tests passing with no failed code checks.

🟡 3 suggestion(s)

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

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

🟡 Suggestion: Use opReturningCompletedResult for self-shield identity operations
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:1924

shieldedShieldFromIdentity returns the identity's post-debit balance but still uses teardownGate.op. If cancellation occurs after the blocking native call completes, withContext can throw during the handoff and discard that balance, leaving the caller unable to distinguish a completed debit from an unstarted operation. The pending-debit guard prevents an immediate double debit, but this sibling should use the same completed-result cancellation contract as the new third-party method and shieldedShieldToRecipient.

): Long = teardownGate.opReturningCompletedResult {

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

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: 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 is a substantial cross-language change to a funds-movement path that debits an identity and shields value to an external recipient, including Rust FFI, JNI marshalling, cancellation semantics, and error handling.
  • 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 quota lookup 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.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 — 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 (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/wallet/PlatformWalletManager.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:1924: Use opReturningCompletedResult for self-shield identity operations
  `shieldedShieldFromIdentity` returns the identity's post-debit balance but still uses `teardownGate.op`. If cancellation occurs after the blocking native call completes, `withContext` can throw during the handoff and discard that balance, leaving the caller unable to distinguish a completed debit from an unstarted operation. The pending-debit guard prevents an immediate double debit, but this sibling should use the same completed-result cancellation contract as the new third-party method and `shieldedShieldToRecipient`.

In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/shielded_send.rs:1406-1418: Factor optional memo C-string decoding into a shared helper
  The new export adds another copy of the unsafe `null` check, `CStr::from_ptr`, UTF-8 conversion, and `ErrorUtf8Conversion` mapping. Equivalent blocks already exist in the transfer path and the address-funded shield-to-recipient path. Keeping this boundary conversion in a shared helper would prevent future changes to host-visible error handling or pointer assumptions from diverging across shielded exports; the existing `encode_memo_text` helper already establishes that the subsequent memo rules should be shared.
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/shielded_send.rs:1432-1449: Trigger recovery sync for ambiguous identity shields
  The identity-funded operation persists its pending debit/redrive before broadcast and can return `ShieldedSpendUnconfirmed` when the outcome is ambiguous. This new worker maps that result directly without calling `poke_sync_on_unconfirmed`, so reconciliation waits for the periodic sync cycle while subsequent identity shields remain blocked by the pending-debit guard. Add the same immediate sync trigger used by the other shielded spend exports before mapping the result.
Out-of-scope follow-up suggestions (1)

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

  • Guard the existing self-shield FFI export against proving-task panics — platform_wallet_manager_shielded_shield_from_identity directly awaits block_on_worker, whose worker join uses expect and can panic if the proving task panics. Unlike the new export and the address-funded recipient shield, this existing extern "C" function has no catch_spend_panic boundary, so a proving panic can abort the host. The function predates this PR and is not changed here, but the adjacent identity-shield API should receive the same protection.
    • Follow-up: Open a follow-up PR that moves the self-shield body into an inner function and wraps the export with catch_spend_panic, preserving the existing ambiguous-spend error contract.

Comment on lines +1406 to +1418
let memo_str = if memo_text.is_null() {
None
} else {
match CStr::from_ptr(memo_text).to_str() {
Ok(s) => Some(s),
Err(e) => {
return PlatformWalletFFIResult::err(
PlatformWalletFFIResultCode::ErrorUtf8Conversion,
format!("memo_text is not valid UTF-8: {e}"),
);
}
}
};

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: Factor optional memo C-string decoding into a shared helper

The new export adds another copy of the unsafe null check, CStr::from_ptr, UTF-8 conversion, and ErrorUtf8Conversion mapping. Equivalent blocks already exist in the transfer path and the address-funded shield-to-recipient path. Keeping this boundary conversion in a shared helper would prevent future changes to host-visible error handling or pointer assumptions from diverging across shielded exports; the existing encode_memo_text helper already establishes that the subsequent memo rules should be shared.

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

Comment on lines +1432 to +1449
let result = block_on_worker(async move {
// SAFETY: valid for the duration of this synchronously-awaited task per
// the caller's documented lifetime contract.
let identity_signer: &VTableSigner = &*(signer_addr as *const VTableSigner);
let prover = CachedOrchardProver::new();
wallet
.shielded_shield_from_identity_to_recipient(
&coordinator,
shielded_account,
&identity_id,
&recipient,
amount,
memo,
identity_signer,
&prover,
)
.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.

🟡 Suggestion: Trigger recovery sync for ambiguous identity shields

The identity-funded operation persists its pending debit/redrive before broadcast and can return ShieldedSpendUnconfirmed when the outcome is ambiguous. This new worker maps that result directly without calling poke_sync_on_unconfirmed, so reconciliation waits for the periodic sync cycle while subsequent identity shields remain blocked by the pending-debit guard. Add the same immediate sync trigger used by the other shielded spend exports before mapping the result.

Suggested change
let result = block_on_worker(async move {
// SAFETY: valid for the duration of this synchronously-awaited task per
// the caller's documented lifetime contract.
let identity_signer: &VTableSigner = &*(signer_addr as *const VTableSigner);
let prover = CachedOrchardProver::new();
wallet
.shielded_shield_from_identity_to_recipient(
&coordinator,
shielded_account,
&identity_id,
&recipient,
amount,
memo,
identity_signer,
&prover,
)
.await
});
let result = block_on_worker(async move {
// SAFETY: valid for the duration of this synchronously-awaited task per
// the caller's documented lifetime contract.
let identity_signer: &VTableSigner = &*(signer_addr as *const VTableSigner);
let prover = CachedOrchardProver::new();
wallet
.shielded_shield_from_identity_to_recipient(
&coordinator,
shielded_account,
&identity_id,
&recipient,
amount,
memo,
identity_signer,
&prover,
)
.await
});
poke_sync_on_unconfirmed(&result, handle);
result

source: gpt-6.1-sol (phase2-reviewer: rust-quality)

@HashEngineering
HashEngineering force-pushed the feat/kotlin-sdk-shield-to-recipient branch from bc2a892 to 22006a2 Compare November 13, 2026 23:03
Base automatically changed from feat/kotlin-sdk-shield-to-recipient to v5.2-dev November 16, 2026 07:10
@github-actions github-actions Bot added this to the v5.2.0 milestone Nov 16, 2026
@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 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

HashEngineering and others added 2 commits November 15, 2026 23:15
Adds the identity-funded third-party shield (Type 21 ShieldFromIdentity with
a recipient) end to end for Android: a new FFI export
platform_wallet_manager_shielded_shield_from_identity_to_recipient over the
existing PlatformWallet::shielded_shield_from_identity_to_recipient, its JNI
bridge, and PlatformWalletManager.shieldedShieldFromIdentityToRecipient. The
Android wallet's External Send (MO-1121) needs it to pay someone else's
Orchard address from an identity balance; shieldedShieldFromIdentity only
targets the wallet's own address.

The FFI body runs under catch_spend_panic, so a panic surfaces as
ErrorShieldedSpendUnconfirmed (18) instead of aborting the host. It decodes
the memo before resolving the wallet, writes out_new_balance only on success,
and maps errors through map_spend_result, which keeps
ErrorShieldedIdentityDebitPending (55) distinct. The identity-debit guard in
rs-platform-wallet is untouched. The docs on every layer say not to retry on
18 or 55, since a retry could debit the identity twice. The Kotlin KDoc also
says a cancelled call may still debit the identity, so it is treated like
ShieldedSpendUnconfirmed. PARITY.md notes the binding as SDK only, with no
Swift counterpart yet.

The JNI and Kotlin layers only marshal: fixed-size ids and recipient, and
sign checks on amount and shieldedAccount before the unsigned casts. A zero
amount, the 32-byte memo limit and the own-IVK recipient rejection stay with
their owners in Rust (book: "validation lives once").

Tests: FFI unit tests for each null required pointer, a bad memo (over-limit
and invalid UTF-8) failing before the wallet is resolved, and an unknown
manager handle leaving out_new_balance untouched; an instrumented
ShieldFromIdentityToRecipientBindingTest that pins the JNI descriptor and
each rejection's layer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ient to a cancelled caller

shieldedShieldFromIdentityToRecipient now runs in
opReturningCompletedResult instead of op, as shieldedShieldToRecipient
does. When the caller is cancelled after the blocking native shield has
completed, the call returns the identity's post-debit balance instead of
throwing CancellationException, so a completed identity debit is never
hidden and prompted to retry. The KDoc's cancellation note is updated to
match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HashEngineering
HashEngineering force-pushed the feat/kotlin-sdk-identity-to-shielded branch from 0bc049d to e8b644b Compare November 16, 2026 07:25
@github-actions

github-actions Bot commented Nov 16, 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 16, 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 new identity-funded third-party shield is consistently marshalled through the Rust FFI, JNI, and Kotlin layers, and the current Kotlin cancellation fix correctly protects the new API's completed result. Rust and Kotlin checks passed; the Swift SDK failure is an unrelated simulator launch failure, so no blocking defect was found.

🟡 3 suggestion(s)

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

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

🟡 Suggestion: Use opReturningCompletedResult for self-shield identity operations
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:1924

The existing self-shield identity method still wraps its blocking native call in teardownGate.op, while the new third-party identity method uses opReturningCompletedResult. If cancellation occurs while the dispatcher hands control back after the native call has already debited the identity, op can discard the returned post-debit balance and expose only CancellationException. The caller then cannot distinguish a completed debit from a failed request and may retry after the durable guard is later reconciled; use the same completed-result handoff as the sibling method.

): Long = teardownGate.opReturningCompletedResult {

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

Still open from earlier rounds (2)

  • 🟡 Suggestion: Trigger recovery sync for ambiguous identity shields — packages/rs-platform-wallet-ffi/src/shielded_send.rs:1432-1449 (thread)
  • 🟡 Suggestion: Factor optional memo C-string decoding into a shared helper — packages/rs-platform-wallet-ffi/src/shielded_send.rs:1406-1418 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: 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 is a large cross-language change that exposes an identity-debit shielded transfer, directly affecting funds movement and signer/FFI handling in shielded_send.rs and the JNI/Kotlin bindings.
  • 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 quota lookup 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.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 — 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 (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/wallet/PlatformWalletManager.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:1924: Use opReturningCompletedResult for self-shield identity operations
  The existing self-shield identity method still wraps its blocking native call in `teardownGate.op`, while the new third-party identity method uses `opReturningCompletedResult`. If cancellation occurs while the dispatcher hands control back after the native call has already debited the identity, `op` can discard the returned post-debit balance and expose only `CancellationException`. The caller then cannot distinguish a completed debit from a failed request and may retry after the durable guard is later reconciled; use the same completed-result handoff as the sibling method.

In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/shielded_send.rs:1432-1449: Trigger recovery sync for ambiguous identity shields
  (carried; thread: https://github.com/dashpay/platform/pull/5896#discussion_r4561681227)
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/shielded_send.rs:1406-1418: Factor optional memo C-string decoding into a shared helper
  (carried; thread: https://github.com/dashpay/platform/pull/5896#discussion_r4561681219)

@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 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants