You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
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.
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.
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.
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: 4
Check name
Status
Explanation
Title check
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
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.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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.
♻️ 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)
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.
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.
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.
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.
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(())
}
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
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.
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.
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
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.
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.
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.
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(());
}
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.
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.
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-actionsBot
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
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.
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)
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.
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
shieldedShieldalways targets the wallet's own address.The FFI
platform_wallet_manager_shielded_shield_to_recipientalready exists, and Swift binds it asPlatformWalletManager.shieldedShieldToRecipient. The Swift example app doesn't call it yet; this binding is added because the Android wallet needs it now.What was done?
FundingNative.shieldedShieldToRecipientinrs-unified-sdk-jni/src/funding.rs. It reusesread_id32,read_recipient43andread_cstring_opt, and maps errors throughtake_pwffi_error. It rejects only what marshaling requires: negative values (before the unsigned cast), a null signer handle, and mis-sized ids.PlatformWalletManager.shieldedShieldToRecipient(walletId, recipientRaw43, amount, shieldedAccount = 0, paymentAccount = 0, memo = null). It runs in the teardown gate and maps errors throughmapNativeErrors, with the same inline preconditions asshieldedShieldandshieldedTransfer. Its KDoc states that:shieldedShield, with the same input selection, fees and signer;shieldedShield;ShieldedSpendUnconfirmed, the caller must not retry.shielded_shield_from_account_implandencode_memo_text. Kotlin passes the memo through untouched.read_cstring_optinfunding.rsused to treat a failedenv.get_stringon a non-null memo as "no memo", so the send went ahead without it. It now throwsDashSDKException(code 1) and the native call isn't made. This also changes the existingshieldedTransfer, which shares the helper.shieldedShieldandshieldedShieldToRecipientKDocs now say inputs are selected in lexicographic Platform-address order (not derivation order).shieldedShieldToRecipientruns inopReturningCompletedResult(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 behindCancellationException.PARITY.mdnotes the binding as SDK only on theSendTransactionViewrow. The SDK parity manifest doesn't list the shield FFIs, so it andPARITY_SUMMARY.mdare unchanged.How Has This Been Tested?
cargo fmt,cargo clippy --all-targetsandcargo test -p rs-unified-sdk-jni(65 passed)../gradlew :sdk:testDebugUnitTest.ShieldToRecipientBindingTest, which needs no wallet, network or funds. It passed 7/7 on an x86_64 API 36 emulator against a freshly builtlibdash_sdk_jni.so. It pins:encode_memo_text.Breaking Changes
None. The change only adds code.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
22006a2kotlin-sdk— you own itpackages/rs-unified-sdk-jni/src/funding.rs) — approved by shumkovWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit