Skip to content

feat(kotlin-sdk): bind Platform → third-party Orchard shield (shieldedShieldToRecipient) - #5873

Merged
HashEngineering merged 7 commits into
v5.2-devfrom
feat/kotlin-sdk-shield-to-recipient
Nov 16, 2026
Merged

HashEngineering merged 7 commits into
v5.2-devfrom
feat/kotlin-sdk-shield-to-recipient

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

The Android Dash wallet's External Send (MO-1121) needs to shield Platform credits to someone else's Orchard address. shieldedShield always targets the wallet's own address.

The FFI platform_wallet_manager_shielded_shield_to_recipient already exists, and Swift binds it as PlatformWalletManager.shieldedShieldToRecipient. The Swift example app doesn't call it yet; this binding is added because the Android wallet needs it now.

What was done?

  • JNI: new export FundingNative.shieldedShieldToRecipient in rs-unified-sdk-jni/src/funding.rs. It reuses read_id32, read_recipient43 and read_cstring_opt, and maps errors through take_pwffi_error. It rejects only what marshaling requires: negative values (before the unsigned cast), a null signer handle, and mis-sized ids.
  • Kotlin: new PlatformWalletManager.shieldedShieldToRecipient(walletId, recipientRaw43, amount, shieldedAccount = 0, paymentAccount = 0, memo = null). It runs in the teardown gate and maps errors through mapNativeErrors, with the same inline preconditions as shieldedShield and shieldedTransfer. Its KDoc states that:
    • it is the same Type 15 shield as shieldedShield, with the same input selection, fees and signer;
    • Rust rejects a recipient the account's own IVK recognizes, so self-shields use shieldedShield;
    • a bound shielded account is still required, because the send is OVK-recorded there as sent history;
    • on ShieldedSpendUnconfirmed, the caller must not retry.
  • Validation lives once: following the book, the zero-amount check and the memo rules (empty means none, at most 32 UTF-8 bytes) stay in Rust, in shielded_shield_from_account_impl and encode_memo_text. Kotlin passes the memo through untouched.
  • Memo read failures now fail closed: read_cstring_opt in funding.rs used to treat a failed env.get_string on a non-null memo as "no memo", so the send went ahead without it. It now throws DashSDKException (code 1) and the native call isn't made. This also changes the existing shieldedTransfer, which shares the helper.
  • Docs: the shieldedShield and shieldedShieldToRecipient KDocs now say inputs are selected in lexicographic Platform-address order (not derivation order).
  • Cancellation: shieldedShieldToRecipient runs in opReturningCompletedResult (added by feat(kotlin-sdk): partial-amount platform-address withdrawal #5830), so a shield that completes after its caller was cancelled returns normally instead of being hidden behind CancellationException.
  • PARITY.md notes the binding as SDK only on the SendTransactionView row. 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, cargo clippy --all-targets and cargo test -p rs-unified-sdk-jni (65 passed).
  • ./gradlew :sdk:testDebugUnitTest.
  • New instrumented ShieldToRecipientBindingTest, which needs no wallet, network or funds. It passed 7/7 on an x86_64 API 36 emulator against a freshly built libdash_sdk_jni.so. It pins:
    • the JNI symbol and descriptor;
    • each JNI boundary rejection (raw code 1, with a message naming the argument, which also pins the argument order);
    • 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 · 22006a2

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals
    • kotlin-sdk — you own it
    • files with no dedicated owner (packages/rs-unified-sdk-jni/src/funding.rs) — approved by 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.

Summary by CodeRabbit

  • New Features
    • Added Kotlin SDK support for shielding funds from a Platform payment account to a third-party Orchard address, with an optional memo.
  • Bug Fixes
    • Invalid amounts, account indices, recipient addresses, and signer handles are rejected during validation. Zero amounts and memo length limits continue to be validated by the native layer.
    • Memo-reading errors are now reported instead of being treated as an absent memo.
    • Improved asset-lock recovery by recognizing InstantSend locks across accounts and using an existing ChainLock proof when available.
  • Documentation
    • Clarified the ordering used to select payment addresses when shielding funds.

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

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

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

Run configuration

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

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The Kotlin SDK adds a wallet-manager method to shield Platform funds to a third-party Orchard address. The call passes through JNI to FFI. Android binding tests cover input validation and error handling. Shield documentation now describes lexicographic Platform-address ordering.

Changes: Recipient shielding

Layer / File(s) Summary
JNI and FFI bridge
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/FundingNative.kt, packages/rs-unified-sdk-jni/src/funding.rs
The JNI declaration and native entry point forward the wallet, account indices, recipient, amount, optional memo, and signer handle. JNI validates inputs. Memo conversion errors now produce an SDK exception instead of being treated as a null memo.
Wallet manager API
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt, packages/kotlin-sdk/PARITY.md
PlatformWalletManager adds shieldedShieldToRecipient, which invokes the native operation through opReturningCompletedResult. Its documentation describes validation, cancellation handling, and memo constraints. The parity entry identifies the Android wallet as the caller. Shield documentation now states that payment-address selection uses lexicographic Platform-address order.
Android binding validation
packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/wallet/ShieldToRecipientBindingTest.kt
Tests check JNI-side rejection, memo-limit handling, and invalid-handle results for well-formed calls.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant PlatformWalletManager
  participant FundingNative
  participant JNIShieldToRecipient
  participant RustFFI
  PlatformWalletManager->>FundingNative: pass recipient-shielding arguments
  FundingNative->>JNIShieldToRecipient: invoke native binding
  JNIShieldToRecipient->>RustFFI: forward validated arguments
Loading
Merge Risk: Minimal · previous review bc2a8

This adds an SDK binding for shielding Platform credits to a third-party Orchard address. No actionable merge-blocking risk was found, and the new binding tests cover input validation and error handling.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a Kotlin SDK JNI binding for shielding Platform credits to a third-party Orchard address via shieldedShieldToRecipient. The changeset adds the PlatformWalletManager AP…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: a Kotlin SDK JNI binding for shielding Platform credits to a third-party Orchard address via shieldedShieldToRecipient. The changeset adds the PlatformWalletManager API, the FundingNative JNI declaration, the Rust JNI function, tests, and docs. The title is 88 characters, which is longer than ideal but still readable and specific.

  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fbeb778 and bc2a892.

Files selected for processing: 1

  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions github-actions Bot added this to the v5.1.0 milestone Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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

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

thepastaclaw commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

♻️ No change to this PR's diff since commit bc2a892 (an empty commit, a merge of the base or a rebase onto it): that review stands — approved; @thepastaclaw review asks for a review of this commit (commit 22006a2)

@HashEngineering HashEngineering self-assigned this Nov 11, 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 1 + Phase 2

The binding correctly forwards the existing Rust recipient-shield operation and preserves validation, lifetime, and error-handling ownership. One in-scope documentation issue remains: the new KDoc describes input selection by derivation order, while the native planner sorts Platform addresses lexicographically. Kotlin CI passed; Rust workspace tests were still running in the supplied CI snapshot.

🟡 1 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.

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); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change adds a contained but cross-language funds-operation binding and boundary tests, without introducing intricate funds-movement logic or changing cryptography or consensus rules.
  • 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)
  • 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.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-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/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:1810-1812: Document lexicographic address selection rather than derivation order
  The native operation does not select inputs in ascending derivation order. `shielded_shield_plan_for_account` passes candidates to `plan_shield_inputs`, which sorts them by `PlatformAddress`; the Rust preflight documentation also specifies lexicographic Platform-address order. Because derivation order and address order can differ, the public KDoc currently gives callers an incorrect expectation about which transparent addresses will fund the payment.

@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 11, 2026
@github-actions

github-actions Bot commented Nov 11, 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 11, 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)

The new Kotlin/JNI binding preserves the existing Rust ownership and lifecycle boundaries, and the Kotlin build/tests have passed. One in-scope suggestion remains: JNI memo-marshaling failures are silently converted into an absent memo before a paid shield proceeds; Rust workspace tests are still in progress.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(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.

Follow-up candidates (optional) (1)

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

🟡 Suggestion: Do not convert memo read failures into no memo
packages/rs-unified-sdk-jni/src/funding.rs:251-255

When env.get_string fails for a non-null memoText, this helper clears the pending JNI exception and returns Ok(None). The new shieldedShieldToRecipient call at lines 774–776 therefore treats a failed memo read exactly like an explicit null or empty memo and continues into the FFI call. A paid Type 15 shield can consequently omit caller-provided memo data without reporting the marshaling failure. Preserve the distinction between an absent memo and a failed JNI read by throwing a DashSDKException or returning Err(()) after clearing the JNI exception, so the native shield is not invoked.

Err(_) => {
    let _ = env.exception_clear();
    throw_sdk_exception(env, 1, &format!("{field} string was invalid"));
    Err(())
}

source: gpt-6.1-sol (phase2-reviewer: architecture-layering)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 5: 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 change adds a Kotlin/JNI binding for a funds-movement operation that selects and shields credits to an externally supplied Orchard recipient, directly affecting coin selection, recipient handling, and transaction construction in the wallet boundary.
  • Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
  • Code unchanged since the last final review (8053d827): 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • 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. 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 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 11, 2026
@github-actions

github-actions Bot commented Nov 12, 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 12, 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 Kotlin/JNI third-party shield binding and fail-closed memo-read change remain correctly layered, with validation and transaction policy delegated to the existing Rust owners. One in-scope documentation inconsistency remains: the sibling JNI shieldedShield KDoc still claims derivation-order input selection even though the implementation and corrected Kotlin docs use lexicographic Platform-address order. Relevant Rust workspace and Kotlin emulator checks passed, with no failed code checks reported.

🟡 1 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: Stale 'ascending derivation order' in shieldedShield JNI doc
packages/rs-unified-sdk-jni/src/funding.rs:670

This JNI KDoc still says shield inputs are selected in ascending derivation order, but plan_shield_inputs sorts candidates by PlatformAddress lexicographically. The sibling Kotlin KDocs were corrected, so this remaining JNI wording contradicts the actual owner and can mislead callers about deterministic input selection.

/// addresses (auto-selected in lexicographic Platform-address order) into the

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

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); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change adds a contained Kotlin/JNI funds-operation binding and adjusts shared memo error handling, but does not introduce large or intricate changes to funds movement, coin selection, or cryptography.
  • 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)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-unified-sdk-jni/src/funding.rs`:
- [SUGGESTION] packages/rs-unified-sdk-jni/src/funding.rs:670: Stale 'ascending derivation order' in shieldedShield JNI doc
  This JNI KDoc still says shield inputs are selected in ascending derivation order, but `plan_shield_inputs` sorts candidates by `PlatformAddress` lexicographically. The sibling Kotlin KDocs were corrected, so this remaining JNI wording contradicts the actual owner and can mislead callers about deterministic input selection.

@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 12, 2026
@github-actions

github-actions Bot commented Nov 12, 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 12, 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 Kotlin/JNI third-party shield binding preserves Rust ownership of recipient validation, input selection, signing, and broadcast behavior, and the supplied CI snapshot shows the relevant Rust and Kotlin checks passing. One related duplicate JNI memo helper still silently drops a supplied token note when JNI string conversion fails.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(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.

Follow-up candidates (optional) (1)

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

🟡 Suggestion: Duplicate read_cstring_opt in tokens.rs still treats a JNI read error as no-note
packages/rs-unified-sdk-jni/src/tokens.rs:141-146

The funding.rs helper was corrected to fail closed when env.get_string fails, but this duplicate helper still clears the JNI exception and returns Ok(None). Its callers then pass a null note pointer to paid token operations, so a supplied public_note can be silently dropped while the operation proceeds. Make this helper throw and return Err(()) on a JNI read failure so all memo-bearing JNI paths have the same fail-closed behavior.

Err(_) => {
    let _ = env.exception_clear();
    throw_sdk_exception(env, 1, "string argument was invalid");
    return Err(());
}

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

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); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The change adds a contained Kotlin/JNI binding and adjusts shared memo error handling, but does not itself introduce large or intricate changes to funds-movement logic, coin selection, or cryptography.
  • 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)
  • Code unchanged since the last final review (8c56c9ef): 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

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

@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 12, 2026
@github-actions

github-actions Bot commented Nov 13, 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 ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. labels Nov 13, 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)

The current head correctly exposes the existing Rust third-party Orchard shield operation through Kotlin and JNI, while keeping validation, memo encoding, recipient semantics, fees, and signer lifetime in their existing owners. The relevant Kotlin and Rust checks reported success, and no new in-scope correctness, security, layering, or documentation issues were found.

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

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: 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 changes the Kotlin/Rust JNI boundary for a funds-movement operation, including Orchard shielding, recipient handling, memo transmission, signer use, and cancellation behavior in PlatformWalletManager.shieldedShieldToRecipient.
  • Phase 1 reviewers: not run (skipped for throughput: 14 PRs queued, above the 10 limit)
  • 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 — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify 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 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 13, 2026
HashEngineering and others added 7 commits November 13, 2026 14:53
…dShieldToRecipient)

Bridges platform_wallet_manager_shielded_shield_to_recipient through a new
JNI export and PlatformWalletManager.shieldedShieldToRecipient, porting
Swift's PlatformWalletManager.shieldedShieldToRecipient. The Android wallet's
External Send (MO-1121) needs it to shield Platform credits to someone
else's Orchard address; shieldedShield only targets the wallet's own.

The Kotlin wrapper states the same sign and recipient-size preconditions as
shieldedShield and shieldedTransfer and passes the memo through untouched:
the memo rules (empty means none, at most 32 UTF-8 bytes) stay in Rust's
encode_memo_text, the single owner.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Instrumented, no-wallet test in the CoreWalletSetGapLimitBindingTest style.
It pins the JNI symbol and descriptor, the per-argument boundary rejections
(raw code 1), Rust's ownership of the memo limit (ErrorInvalidParameter from
encode_memo_text) and the FFI invalid-handle path for well-formed calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ient to Rust

The JNI bridge and the Kotlin wrapper rejected amount == 0, duplicating the
check shielded_shield_from_account_impl already owns (book: "validation lives
once"). Both now reject only negative amounts, which they must do before the
unsigned cast. The binding test pins a negative amount to the JNI layer and a
zero amount to the FFI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…parity row

- The shieldedShield and shieldedShieldToRecipient KDocs said inputs are
  selected in ascending derivation order. plan_shield_inputs sorts the
  candidates by PlatformAddress, so the order is lexicographic.
- shieldedShieldToRecipient: cancelling the caller does not stop the
  native call, so the shield can still land. Treat a cancelled call like
  ShieldedSpendUnconfirmed and let the next sync reconcile before retrying.
- PARITY.md: note the SDK-only shieldedShieldToRecipient binding on the
  SendTransactionView row, as the earlier SDK-only bindings did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
read_cstring_opt in funding.rs turned a failed env.get_string on a
non-null memo into Ok(None), so shieldedShieldToRecipient and the
existing shieldedTransfer went ahead as a paid send without the memo the
caller supplied. It now throws DashSDKException (code 1) and returns
Err(()), so the native call is not made.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The doc comment on the shieldedShield JNI export still said inputs are
auto-selected in ascending derivation order. plan_shield_inputs sorts
them by PlatformAddress, so the order is lexicographic, matching the
Kotlin KDocs corrected earlier in this PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ncelled caller

shieldedShieldToRecipient now runs in opReturningCompletedResult (#5830)
instead of op. When the caller is cancelled after the blocking native
shield has completed, the call returns normally instead of throwing
CancellationException, so a shield that landed is never hidden and
prompted to retry. The KDoc's cancellation note is updated to match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@HashEngineering
HashEngineering force-pushed the feat/kotlin-sdk-shield-to-recipient branch from bc2a892 to 22006a2 Compare November 13, 2026 23:03
@HashEngineering
HashEngineering changed the base branch from v5.1-dev to v5.2-dev November 13, 2026 23:04
@github-actions github-actions Bot modified the milestones: v5.1.0, v5.2.0 Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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

@HashEngineering

Copy link
Copy Markdown
Collaborator Author

/self-reviewed

@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: QuantumExplorer or shumkov.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Nov 16, 2026
@HashEngineering
HashEngineering merged commit f465de2 into v5.2-dev Nov 16, 2026
33 checks passed
@HashEngineering
HashEngineering deleted the feat/kotlin-sdk-shield-to-recipient branch November 16, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants