Repository navigation
feat(kotlin-sdk): shield from identity to a third-party Orchard address - #5896
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
⚡ Priority review — starts as soon as a slot frees (commit defca9c) · queue and estimated start |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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_shieldandplatform_wallet_manager_shielded_shield_from_identityexports callblock_on_workerwithoutcatch_spend_panic. Sinceblock_on_workerre-panics when its proving task panics, an unwind can abort the host at theextern "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_panicand adds panic-to-ErrorShieldedSpendUnconfirmedcoverage matching the existing guard tests.
- Follow-up: Open a focused follow-up PR that wraps both older shield exports in
fbeb778 to
bc2a892
Compare
…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 <[email protected]>
8b08328 to
0bc049d
Compare
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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_identitydirectly awaitsblock_on_worker, whose worker join usesexpectand can panic if the proving task panics. Unlike the new export and the address-funded recipient shield, this existingextern "C"function has nocatch_spend_panicboundary, 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.
- Follow-up: Open a follow-up PR that moves the self-shield body into an inner function and wraps the export with
bc2a892 to
22006a2
Compare
|
Bots are done — your move: post |
|
Bots are done — your move: post |
0bc049d to
e8b644b
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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)
|
Bots are done — your move: post |
e8b644b to
5b65609
Compare
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Updated after discussion: 1 finding(s) of this review were settled in the inline threads; 1 blocking finding(s) still stand.
- ✅ Withdrawn: 🟡 Use one public error type for malformed shield arguments
The Kotlin/JNI bridge matches the Rust export, but the new admission gate protects only one Kotlin manager and only while the call is running. The Rust reset path can still erase the recovery record for an unresolved identity debit, so the funds-safety check belongs in the Rust wallet. The Kotlin emulator and Rust workspace checks passed on this head; PR Hygiene and PastaClaw review were pending.
🔴 1 blocking | 🟡 3 2 suggestion(s)
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: Pass a live signer to tests that reach the Rust export
packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/wallet/ShieldFromIdentityToRecipientBindingTest.kt:43-44
The dead manager is a registry ID that Rust can safely reject, but DUMMY_SIGNER = 1L becomes a raw pointer. The FFI contract requires a live callback signer even when the manager ID is invalid. The test passes today only because Rust resolves the manager before borrowing the signer; a valid refactor could reverse those steps and crash instrumentation. Create a signer with SignerNative.createSigner and a no-key bridge, then destroy it in cleanup. Keep 0L for the explicit JNI null-signer test.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
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.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — PlatformWalletManager.shieldedShieldFromIdentityToRecipient opens a new funds-movement path in Kotlin whose cancellation and teardown coordination must preserve the completed debit result and prevent deletion of the durable retry record while payment is in flight. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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)
- Code unchanged since the last final review (
e8b644b7): 1 new suggestion(s) listed as follow-up candidates, not posted inline - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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/NativeOpAdmission.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/NativeOpAdmission.kt:24-47: Protect unresolved identity debits in the Rust wallet
This counter decides whether destructive operations may touch Rust-owned wallet state. The book’s “FFI and mobile SDKs hold no business logic” rule puts that decision in `rs-platform-wallet`, not in a binding. Only the recipient wrapper enters this gate: the self-shield reaches the same Rust implementation without it, while a recipient send from wallet A blocks removal of unrelated wallet B. Separate managers can also open the same SQLite path because `configure_shielded` checks only its own coordinator slot. A reset through the second manager can therefore delete the first manager’s pending row while the send is still running. Even with one manager, the counter drops on `ShieldedSpendUnconfirmed`; following the new “retry once it returns” guidance can then reach `purge_all_subwallets`, which deletes the row needed to recover the original debit and refuse a fresh one after rebind or reopen. Enforce live exclusion in Rust at the shared store boundary (or enforce exclusive store ownership), scope removal to the affected wallet, and refuse destructive operations before mutation or preserve and rehydrate unresolved guards. Keep `TeardownGate` for the separate signer-lifetime concern. Cover both overlapping access to one store and reset after an ambiguous return, and update the clear and removal KDocs to distinguish call completion from reconciliation.
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:2004-2006: Decode code 39 credit amounts without losing unsigned precision
The new method accepts `Long.MAX_VALUE`, and Rust adds the positive shield fee floor in `u64` before checking the balance. The FFI can therefore return code 39 with an unquoted `required` above `Long.MAX_VALUE`. Android’s `JSONObject` reads that token as a `Double`, and `requiredULong` then fails to parse its scientific notation, so `DashSdkError` returns `PlatformWallet.Generic` instead of the documented typed refusal. Decode the original numeric token as `ULong`, as `DocumentHistory.kt` does, and cover an unquoted value above the signed range in a mapping test.
- [SUGGESTION → WITHDRAWN in discussion; do not fix] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:2051-2061: Use one public error type for malformed shield arguments
A malformed `walletId` reaches JNI and is mapped to `DashSdkError.InvalidParameter`, while a malformed `identityId` throws `IllegalArgumentException` from `require`. JNI already checks both ID widths, the recipient width, and signed inputs before passing pointers or casting values. Let those checks report through `mapNativeErrors` so a caller can handle malformed arguments consistently.
In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:515-518: Scope the no-broadcast guarantee to identity shield preflight
Code 39 does not tell callers whether a transition was submitted. A DPNS purchase can pass its local preflight and receive `IdentityInsufficientBalanceError` from Platform; `promote_document_trade_error` maps that rejection to the same `InsufficientIdentityCredits` type. Keep the stronger guarantee on the shield methods, where the proved-balance check really does precede signing.
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.
- Preserve completed results for the existing Kotlin self-shield — The base self-shield uses
teardownGate.op, so cancellation on the return dispatch can hide a successful debit. This PR changes that method’s refusal KDoc, not its dispatch or execution path.- Follow-up: Use
opReturningCompletedResultin a separate Kotlin SDK PR and test cancellation after native success.
- Follow-up: Use
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
No blocking issue found at 0ff4392. The recipient API now correctly describes its return as a balance snapshot, not a payment receipt; the remaining findings concern memo marshalling, documentation, and binding-test coverage. The Kotlin emulator build and tests and the Rust workspace tests passed; PR Hygiene and the automated review were pending.
🟡 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: Describe the self-shield return as a balance snapshot too
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:1932-1934
The new recipient KDoc links to shieldedShieldFromIdentity, but the self-shield KDoc still calls its result a proven post-debit balance and says the balance proof confirms the operation. Both methods use the same Rust implementation: it accepts a verified balance snapshot, can return a newer cached balance, and leaves the activity pending until the shielded scan observes the note commitments. Align the self-shield return documentation so callers do not infer a stronger guarantee from the linked method.
* @return the funding identity's credit balance from the verified snapshot,
* or a newer balance already known to the wallet. This balance does not
* confirm the debit; the shielded scan confirms the activity separately.
source: muse-spark-1.3-contributor (phase1-reviewer: general)
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: Test wallet-ID forwarding through the public Kotlin method
packages/kotlin-sdk/sdk/src/androidTest/kotlin/org/dashfoundation/dashsdk/wallet/ShieldFromIdentityToRecipientBindingTest.kt:155-162
The width tests distinguish the IDs at JNI entry, but every call goes directly through FundingNative with a dead manager. Swapping the two valid 32-byte IDs in the public wrapper or in the JNI-to-FFI call would still pass. Add an offline case that calls PlatformWalletManager.shieldedShieldFromIdentityToRecipient on a live, empty manager with distinct IDs and checks that the mapped WalletOperation names the supplied wallet ID. The FFI returns wallet not found with that ID before it requires a configured shielded coordinator or does network work.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, security-auditor)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 8: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 9: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a sizable cross-language change that exposes identity-funded shielding to a third-party recipient, directly affecting funds movement, signing, and JNI marshalling in FundingNative and PlatformWalletManager. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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 final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Code unchanged since the last final review (
edf8c891): 1 new nitpick(s) dropped; 1 new suggestion(s) listed as follow-up candidates, not posted inline - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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:920-925: Reject malformed UTF-16 before sending a recipient memo
This new payment path uses `read_cstring_opt`, whose `env.get_string(...).into()` conversion falls back to lossy decoding in the pinned `jni` 0.21.1. A Java string containing an unpaired surrogate can therefore become replacement characters before it reaches `encode_memo_text`. If the substituted text fits the 32-byte limit, Rust accepts it and the recipient can receive a different memo from the one the caller supplied. Decode strictly in the shared JNI reader, before the FFI call, and test both an unpaired surrogate and a valid supplementary character. Leave the memo length rule in Rust.
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:1984-1985: Distinguish the admission fee floor from the fee charged
`shield_from_identity_to` calculates code 39's `required` by adding `compute_shielded_identity_balance_write_fee(2, ...)` to the amount. DPP defines that value as the admission floor and explicitly says the metered execution fee can be lower. An External Send caller should not display `requiredCredits - amount` as the fee that would be charged. Make the same distinction in the self-shield refusal paragraph and the `InsufficientIdentityCredits` KDoc.
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/wallet/PlatformWalletManager.kt:1932-1934: Describe the self-shield return as a balance snapshot too
The new recipient KDoc links to `shieldedShieldFromIdentity`, but the self-shield KDoc still calls its result a proven post-debit balance and says the balance proof confirms the operation. Both methods use the same Rust implementation: it accepts a verified balance snapshot, can return a newer cached balance, and leaves the activity pending until the shielded scan observes the note commitments. Align the self-shield return documentation so callers do not infer a stronger guarantee from the linked method.
Out-of-scope follow-up suggestions (2)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Protect unresolved identity debits across wallet reset and removal — The existing Rust reset and removal paths can delete the durable records that prevent a second identity debit. The Kotlin binding calls the same native implementation already used by Swift and direct C callers; it does not change when the guard is written or deleted.
- Correct the balance and recovery guarantees in the C export documentation — The unchanged C export documentation from #5863 still calls the result a proven post-debit balance and promises reconciliation on the next sync. Direct callers need the same distinction now made in Kotlin: a balance snapshot is not a payment receipt, and a sync can leave a debit unresolved.
- Follow-up: Update the Rust FFI documentation in a separate PR. Keep execution-proof binding under #4270.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
… floor accurately - shieldedShieldFromIdentity (and its FundingNative/JNI docs) called its result a proven post-debit balance, as the recipient variant did before 0ff4392. Both use the same Rust path: a verified balance snapshot or a newer known balance, with the activity confirmed by the shielded scan. - For a shield, code 39's `required` is the amount plus DPP's admission fee floor (compute_shielded_identity_balance_write_fee), which the metered fee can undercut. Say so in both shields' refusal paragraphs and in InsufficientIdentityCredits, so a caller does not show required - amount as the fee charged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y-to-recipient shield walletId and identityId are both 32 bytes, so the JNI width checks cannot tell them apart and every existing case calls FundingNative directly with a dead handle. Call PlatformWalletManager.shieldedShieldFromIdentityToRecipient on a live, empty, offline manager with distinct ids: the FFI resolves the wallet first and fails with "wallet not found: <hex wallet id>" before it needs a coordinator, signer or network. Swapping the ids in the wrapper makes this test fail with the identity id in that message. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The Kotlin and JNI additions correctly forward the identity, recipient, amount, memo, and signer to the existing Rust export, and the documented balance/error semantics are now aligned. One in-scope suggestion remains: the new paid-memo path reuses a JNI conversion that can lossily replace an unpaired UTF-16 surrogate before Rust validates the memo; no tracking issue is linked for the proposed shared-decoder follow-up. Kotlin emulator and Rust workspace checks passed, with review and PR Hygiene checks still pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — The sizable cross-language change directly exposes identity-funded shielding and amount/error handling for funds movement in the JNI and Kotlin wallet APIs. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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.
Out-of-scope follow-up suggestions (2)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Align Swift and C export documentation with the balance contract — The unchanged Swift wrapper and Rust C export still describe the returned identity balance as a proven post-debit balance, while the Kotlin documentation now correctly explains that it is a balance snapshot and does not confirm execution of this particular debit.
- Follow-up: Open a follow-up documentation PR updating the Swift wrapper and Rust C export comments to distinguish the returned balance from confirmation of the outgoing activity.
- Use one public error type for malformed shield arguments — Withdrawn because this wrapper follows the existing sibling convention of using Kotlin preconditions for fixed-width and signed arguments; changing only this method would create an inconsistent public contract, while a uniform migration is outside this binding-only change.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
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.
shieldedShieldFromIdentityalways targets the wallet's own address.#5863 added the FFI export
platform_wallet_manager_shielded_shield_from_identity_to_recipient(with Swift's binding) and a proved-balance check before an identity-funded shield is armed. This PR adds the JNI bridge and Kotlin binding over that export, and the Kotlin side of the check's new refusal.Builds on #5873 (Kotlin
shieldedShieldToRecipient), #5863 and #5860, all merged intov5.2-dev. An earlier version of this PR carried its own copy of the FFI export with the same signature; after #5863 merged, that copy was dropped, so this PR changes no Rust FFI code.What was done?
FundingNative.shieldedShieldFromIdentityToRecipientinrs-unified-sdk-jni/src/funding.rs, which returns the funding identity's credit balance from the verified snapshot (not a receipt for this debit; binding the proof to execution is Bind affected-state proofs to transition execution #4270). It reusesread_id32,read_recipient43andread_cstring_opt, and rejects only what marshalling requires: negative values (before the unsigned cast), a null signer handle, and mis-sized ids.PlatformWalletManager.shieldedShieldFromIdentityToRecipient(walletId, identityId, recipientRaw43, amount, shieldedAccount = 0, memo = null): Long. It maps errors throughmapNativeErrorsand signs with the identity signer, asshieldedShieldFromIdentitydoes. It runs inteardownGate.opReturningCompletedResult(feat(kotlin-sdk): partial-amount platform-address withdrawal #5830), asshieldedShieldToRecipient(feat(kotlin-sdk): bind Platform → third-party Orchard shield (shieldedShieldToRecipient) #5873) does. Its KDoc states that:shieldedShieldFromIdentity;InsufficientIdentityCredits(39) andIdentityBalanceUnavailable(58) are refusals before anything is signed or broadcast;ShieldedSpendUnconfirmedorShieldedIdentityDebitPending, because a retry could debit the identity twice;CancellationException;requiredis the amount plus DPP's admission fee floor, which the metered fee can undercut, so the KDocs sayrequired - amountis not the fee charged. Both identity shields now describe their return as a balance snapshot, not a receipt.InsufficientIdentityCredits(39) orIdentityBalanceUnavailable(58, typed in Kotlin by feat(platform-wallet)!: top up an identity the wallet does not manage from Platform addresses #5860), so the KDocs ofshieldedShieldFromIdentityandshieldedShieldFromIdentityToRecipientlist both.InsufficientIdentityCredits' KDoc no longer describes only DPNS purchases, and says that only the identity shields refuse before signing (a DPNS purchase can get code 39 after Platform rejects a submitted transition). The new method's KDoc says sync only attempts to reconcile an ambiguous debit and points atshieldedIdentityDebitRecoveryRecords; a completed sync is not permission to resubmit.org.json. Android'sorg.jsonread a code-39requiredaboveLong.MAX_VALUE(reachable here, since the amount may be up toLong.MAX_VALUEand Rust adds the fee inu64) as aDouble, and the mapping fell back toPlatformWallet.Generic. String fields must now be JSON strings, so a null one fails closed toGeneric.shielded.shield_from_identity_to_recipientcapability (added by feat(swift-sdk): shieldedShieldFromIdentityToRecipient #5863) now marks the Kotlin SDKsupported, verified on device byShieldFromIdentityToRecipientBindingTest;PARITY_SUMMARY.mdis regenerated.PARITY.mdnotes the binding as SDK only, no UI, on theSendTransactionViewrow.How Has This Been Tested?
cargo fmtandcargo clippy --all-targets -D warningsonrs-unified-sdk-jni;cargo test -p rs-unified-sdk-jni../gradlew :sdk:testDebugUnitTest, including newDpnsMarketplaceErrorTestcases for a code-39u64::MAXamount, a non-stringidentityIdand code 40 (the first two fail against the oldorg.jsonparser).python3 scripts/check_sdk_parity_manifest.py.New instrumented
ShieldFromIdentityToRecipientBindingTest, which needs no wallet, network or funds, run on an x86_64 API 36 emulator against alibdash_sdk_jni.sofreshly built from this PR's head (that is, against feat(swift-sdk): shieldedShieldFromIdentityToRecipient #5863's export). It uses a real native signer over a bridge that holds no keys, so no call dereferences a bogus pointer. It pins:encode_memo_text;PlatformWalletManagermethod on a live, empty, offline manager, the FFI's wallet lookup naming the wallet id it received, so the two 32-byte ids cannot be swapped between Kotlin and the FFI unnoticed (checked by swapping them in the wrapper, which fails the test).Result: 14/14 together with
ShieldToRecipientBindingTeston emulator (Pixel 9 Pro, API 36).Known gap (Rust, not addressed here)
removeWalletandclearShieldedStoragedo not wait for an in-flight identity debit, and Rust'sNetworkShieldedCoordinator::clear→FileBackedShieldedStore::purge_all_subwalletsdeletes everyshielded_pending_spendsrow, including an unresolved identity-debit guard (also after aShieldedSpendUnconfirmedreturn). A later call could then sign again. This is pre-existing and applies equally toshieldedShieldFromIdentity, the other Kotlin shielded spends and Swift'sclearShielded. Whether destructive operations may run while an identity debit is unresolved is a decision about Rust-owned wallet state, so it belongs inrs-platform-wallet; the live spend/clear exclusion is tracked in #5868. An earlier revision of this PR added a Kotlin-side admission counter; it was reverted because it covered only this wrapper and only the live call.Breaking Changes
None. Code 39 and 40 details that are malformed (for example a null string field) now map to
PlatformWallet.Genericinstead of a typed error carrying the text "null".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 ·
defca9cWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.