Repository navigation
feat(platform-wallet): report whether a failed payment may have left the wallet - #5928
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit 81671e6) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The Rust-owned delivery classification is exhaustive and is propagated through most JNI and FFI paths, but several adapters still discard or reconstruct authoritative metadata. Swift loses precise per-result delivery, shielded asset-lock funding can flatten a NotSent error to MaybeSent, and Kotlin implements retry policy in the binding layer rather than receiving a Rust-owned disposition. The CI snapshot contains no failed code checks; Kotlin tests passed while Rust and Swift jobs were skipped.
🔴 3 blocking | 🟡 4 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Shielded asset-lock funding drops the wallet error's delivery class
packages/rs-platform-wallet-ffi/src/shielded_send.rs:886-889
The fallback arm of map_asset_lock_funding_result has the original typed PlatformWalletError, but constructs ErrorWalletOperation without stamping e.payment_delivery(). The constructor therefore supplies the shared code default, MaybeSent, even for a NotSent error such as ShieldedNoUnspentNotes, ProtocolVersionNotActive, or another pre-dispatch SDK refusal. The same unstamped fold exists in the shielded seed-pool export around lines 2158-2161. Both fresh and resumed asset-lock funding can therefore contradict the Rust classifier and make hosts wait for sync instead of retrying a payment that never dispatched.
Err(e) => {
let delivery = e.payment_delivery();
PlatformWalletFFIResult::err(
PlatformWalletFFIResultCode::ErrorWalletOperation,
format!("{operation} failed: {e}"),
)
.with_payment_delivery(delivery)
}
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.1-sol (phase2-reviewer: general)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (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) — The large diff changes payment error classification and retry behavior across rs-platform-wallet, FFI, JNI, Kotlin, and Swift, directly affecting funds-movement outcomes and wallet recovery decisions, including coin-selection and held-lock handling in packages/rs-platform-wallet/src/error.rs. - 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/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:995-999: Swift discards the result-specific payment-delivery class
`PlatformWalletResult.paymentDelivery` reads the precise `inner.payment_delivery` value, but `PlatformWalletError.init(result:)` drops that field and `PlatformWalletError.delivery` reconstructs delivery from the result code. Shared codes such as `ErrorWalletOperation` and `ErrorUnknown` can carry a Rust-proven `NotSent` result, for example after a pre-dispatch transaction-build or persistence failure, but Swift reports `.maybeSent` because those codes also represent ambiguous failures. Kotlin preserves the native value through `DashSDKException`, so the two host APIs disagree and Swift cannot offer a safe retry that Rust has already authorized. Preserve the result-level delivery value in the Swift error representation instead of recomputing it from `resultCode`.
In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/shielded_send.rs:886-889: Shielded asset-lock funding drops the wallet error's delivery class
The fallback arm of `map_asset_lock_funding_result` has the original typed `PlatformWalletError`, but constructs `ErrorWalletOperation` without stamping `e.payment_delivery()`. The constructor therefore supplies the shared code default, `MaybeSent`, even for a `NotSent` error such as `ShieldedNoUnspentNotes`, `ProtocolVersionNotActive`, or another pre-dispatch SDK refusal. The same unstamped fold exists in the shielded seed-pool export around lines 2158-2161. Both fresh and resumed asset-lock funding can therefore contradict the Rust classifier and make hosts wait for sync instead of retrying a payment that never dispatched.
In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:130-136: Kotlin binding implements retry policy from delivery metadata
`unlessMaybeSent` and the changed `isRetryable` overrides turn the native delivery signal into a retry decision inside the Kotlin SDK, including a Kotlin-specific exception for `AssetLockInputContested`. The repository's mobile-layer rule places orchestration and decisions in `rs-platform-wallet`; FFI crates and Swift/Kotlin SDKs marshal Rust-owned decisions. `PaymentDelivery` only describes whether a payment may already exist; it does not express whether a retry resumes a held lock or creates a second payment. Emit the required retry/resume disposition from the Rust wallet and marshal it, rather than deriving policy from error subclasses in Kotlin.
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:60-66: Shielded identity-create errors lose delivery metadata in Kotlin
`DashSdkError.delivery` only reads metadata from a `DashSDKException` cause. The shielded identity-create JNI path handles code 17 separately, returning a tagged `[tag || identity_id || diagnostic]` payload; `decodeShieldedCreatePayload` then constructs `ShieldedCreateUnconfirmed` without a native exception cause. Consequently, this genuinely ambiguous payment exposes `delivery == null` instead of `PaymentDelivery.MAYBE_SENT`, so callers cannot use the new delivery property consistently for this important path. Carry the delivery value through the tagged payload or attach an equivalent native error cause when constructing the typed exception.
In `packages/rs-platform-wallet-ffi/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:996-1001: Document or version the by-value FFI ABI change
`PlatformWalletFFIResult` is `#[repr(C)]` and returned by value from C functions. Adding `payment_delivery` changes its size and can change the platform-specific aggregate return ABI; a caller compiled against the previous header can misinterpret the returned value even though a coordinated source rebuild works. The comment currently describes appending the field as source-compatible rather than an ABI break, while the repository's own FFI documentation recognizes field additions to C structs as ABI breaks. Add an explicit ABI/version coordination guarantee or expose a versioned result shape, and do not imply compatibility with already-built host binaries.
In `packages/rs-platform-wallet/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/error.rs:1500-1511: Wire the held asset-lock accessor to a typed host field
`held_asset_lock()` is a new public helper, but the repository has no non-test caller and `PlatformWalletFFIResult`/JNI do not carry an outpoint. Hosts therefore still have to recover the resume outpoint from the formatted error message if they need this information. That leaves the new structured accessor disconnected from the mobile paths that need to resume a held lock. Either carry the optional outpoint through the FFI result and JNI/SDK adapters, or keep the helper private until a typed consumer exists.
- [SUGGESTION] packages/rs-platform-wallet/src/error.rs:2377-2466: Payment-delivery tests do not cover most classified variants
The exhaustive match forces new variants to receive a class, but the table test pins only a small subset of the wallet error variants. It does not exercise several safety-relevant arms, including persistence failures, asset-lock proof/expiry failures, `QuorumNotVerified`, `SpvError`, `TokenError`, shielded sync/tree failures, and contact-request gates. A mistaken class in any uncovered arm still compiles and passes. Add table rows for every variant, or generate the coverage table from the same classification source so the safety contract cannot silently drift.
|
On the finding about shielded asset-lock funding: fixed in cb8b995. A new |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Most of the payment-delivery transport is now present, but this head still leaves retry/resume policy in Kotlin and maintains a second code-based delivery policy in the FFI adapter. Swift's special shielded identity-create error also drops the delivery field, and the exhaustive FFI mapping has only sample coverage. No code check is failing in the supplied CI snapshot; Kotlin passed, while Rust and Swift checks are skipped and review/hygiene checks remain pending.
🔴 2 blocking | 🟡 1 suggestion(s)
Still open from earlier rounds (1)
- 🔴 Blocking: Kotlin binding implements retry policy from delivery metadata —
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:144-163(thread)
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: Swift shielded identity-create error drops Rust payment-delivery metadata
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletManagerShieldedSync.swift:1542-1551
The regular PlatformWalletError path now preserves wrapped.paymentDelivery, but the special Type-20 unconfirmed path constructs ShieldedIdentityCreateUnconfirmedError with only identityId and message. This important ambiguous-payment result therefore does not expose the Rust-owned delivery classification to Swift callers, unlike the corresponding Kotlin path and ordinary wallet errors. Add a delivery property to the custom error and pass wrapped.paymentDelivery when throwing it.
source: gpt-6.1-sol (phase2-reviewer: general)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (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) — The large cross-language diff changes payment failure recovery and asset-lock resumption behavior, directly affecting funds movement and whether wallets fund new payments or resume held locks. - 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 (
36f17e01): 1 new suggestion(s) listed as follow-up candidates, not posted inline - 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/rs-platform-wallet-ffi/src/error.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/error.rs:796-888: FFI result-code mapping reimplements the wallet's delivery policy
`PlatformWalletFFIResultCode::payment_delivery()` is a second delivery-policy table in the FFI adapter. `PlatformWalletFFIResult::err` stamps this code-derived class onto raw results, while `From<PlatformWalletError>` later overwrites it with the wallet error's more precise classification; consequently, the same FFI code has multiple semantic sources, and raw or future FFI paths can silently expose a class that does not describe the underlying operation. This is business policy in the adapter rather than marshaling. Have the owning Rust operation provide an explicit disposition and have FFI copy it; use an explicit unknown/non-payment state for results that have no wallet error instead of maintaining a second policy table.
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:3705-3740: Exhaustive FFI delivery-code mapping is only partially tested
`PlatformWalletFFIResultCode::payment_delivery()` is a safety-sensitive code-only fallback used by `PlatformWalletFFIResult::err` and the exported `platform_wallet_ffi_result_code_payment_delivery` helper, but the test covers only five of the mapping's many codes. The separate exhaustive `PlatformWalletError` table cannot detect an incorrect class for groups such as persister codes 49–54, deferred-reservation codes 34–36, or contact-request codes 68–76. Add a table covering every `PlatformWalletFFIResultCode` and assert both the result constructor and exported helper against it.
In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:144-163: Kotlin binding implements retry policy from delivery metadata
(carried; thread: https://github.com/dashpay/platform/pull/5928#discussion_r4578895207)
|
Also fixed: the Swift |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The Rust, FFI, JNI, and Kotlin paths preserve the wallet-owned delivery and retry metadata, but Swift still drops it for several result-derived NotSent failures. Panic fallbacks also return Unknown metadata despite using operation-specific ambiguous-payment error codes. Kotlin tests passed in CI; Rust and Swift checks were skipped, with no failed code checks reported.
🔴 1 blocking | 🟡 1 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Ambiguous panic fallbacks lose payment-delivery metadata
packages/rs-platform-wallet-ffi/src/error.rs:1791-1799
catch_panic_to_code converts every panic to PlatformWalletFFIResult::err, which now deliberately sets payment_delivery to Unknown and retryable to false. However, catch_spend_panic and catch_funding_panic select ErrorShieldedSpendUnconfirmed and ErrorTransactionBroadcastUnconfirmed specifically because a panic may occur after note reservation or broadcast; their documented contracts identify an ambiguous payment outcome. Hosts therefore cannot distinguish these known ambiguous payment failures from an unclassified FFI-boundary error. Pass an explicit payment class to the panic helper for these payment wrappers, using MaybeSent with retryable = false, while retaining Unknown for read-only or non-payment panic paths, and assert the fields in the panic tests.
source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality, security-auditor)
Still open from earlier rounds (1)
- 🔴 Blocking: Swift discards the result-specific payment-delivery class —
packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:1264-1267(thread)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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, intricate cross-language change that alters failed-payment handling, asset-lock resumption, and wallet funds-flow classification across Rust, FFI, JNI, Kotlin, and Swift. - 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— platform-versioning (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/rs-platform-wallet-ffi/src/error.rs`:
- [SUGGESTION] packages/rs-platform-wallet-ffi/src/error.rs:1791-1799: Ambiguous panic fallbacks lose payment-delivery metadata
`catch_panic_to_code` converts every panic to `PlatformWalletFFIResult::err`, which now deliberately sets `payment_delivery` to `Unknown` and `retryable` to false. However, `catch_spend_panic` and `catch_funding_panic` select `ErrorShieldedSpendUnconfirmed` and `ErrorTransactionBroadcastUnconfirmed` specifically because a panic may occur after note reservation or broadcast; their documented contracts identify an ambiguous payment outcome. Hosts therefore cannot distinguish these known ambiguous payment failures from an unclassified FFI-boundary error. Pass an explicit payment class to the panic helper for these payment wrappers, using `MaybeSent` with `retryable = false`, while retaining `Unknown` for read-only or non-payment panic paths, and assert the fields in the panic tests.
In `packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/PlatformWalletResult.swift:1264-1267: Swift discards the result-specific payment-delivery class
(carried; thread: https://github.com/dashpay/platform/pull/5928#discussion_r4578895203)
|
Also done in 1924bc2 (the panic suggestion at |
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; 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
The Rust wallet classification and FFI/JNI/SDK transport are consistent on this head, and the ten prior findings are fixed. However, Swift and Kotlin example applications still derive payment outcomes from error subclasses, while FFI panic wrappers hard-code payment policy outside the wallet owner; both can undermine the PR's stated duplicate-payment safety goal. The public AddressNonceMismatch guidance also contradicts its new MaybeSent/non-retryable classification. The Rust workspace check remains in progress; no failed code checks are present in the CI snapshot.
🔴 2 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Application layers still derive payment delivery from error-type lists
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactRequestOutcomes.swift:120-138
The Swift helper returns mayHaveGoneThrough only for .shieldedSpendUnconfirmed and .transactionBroadcastUnconfirmed, then treats every other PlatformWalletError as an ordinary failure. The Kotlin equivalent at packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ContactRequestOutcomes.kt:116-128 has the same issue, and the shielded send helpers at packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/ViewModels/SendViewModel.swift:849-857 and packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt:804-813 enumerate subclasses instead of reading native metadata. A shared result code can carry a Rust-classified MaybeSent or LockHeld result that is not represented by the selected subclass, causing the UI to present an uncertain payment as a normal failure and permit a fresh submission. These application consumers must honor PlatformWalletError.delivery/isRetryable and DashSdkError.delivery/isRetryable first; retain only application-specific states such as contact-request holds after checking the native class.
source: gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
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: AddressNonceMismatch documentation still promises an unsafe retry
packages/rs-platform-wallet/src/error.rs:834-842
payment_delivery() classifies AddressNonceMismatch as MaybeSent, and is_retryable() therefore returns false. The public documentation and rendered error still tell callers to rebuild and retry with the expected nonce. Following that text instead of the new Rust-owned retry field can resubmit a transition after an earlier dispatch and potentially create a duplicate payment. The documentation and error text must require reconciliation before another submission.
/// Platform rejected an address-funds transition because a spent address's
/// provided nonce did not equal its expected next value (DPP consensus code
/// 40603, `AddressInvalidNonceError`). An endpoint verdict may follow an
/// earlier dispatch, so the wallet classifies this as
/// [`PaymentDelivery::MaybeSent`]; reconcile the original operation before
/// submitting another transition.
#[error(
"Address nonce mismatch for {address}: submitted nonce {provided_nonce}, \
Platform expected {expected_nonce}; reconcile the original operation \
before submitting another transition"
)]
source: gpt-6.1-sol (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.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, intricate cross-language change that alters platform-wallet payment delivery classification and retry/resume behavior for funds movement and asset-lock handling, particularly in packages/rs-platform-wallet/src/error.rs and its FFI/JNI/Swift/Kotlin boundary code. - 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 (
c7910c4e): 1 new suggestion(s) listed as follow-up candidates, not posted inline - 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/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactRequestOutcomes.swift`:
- [BLOCKING] packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactRequestOutcomes.swift:120-138: Application layers still derive payment delivery from error-type lists
The Swift helper returns `mayHaveGoneThrough` only for `.shieldedSpendUnconfirmed` and `.transactionBroadcastUnconfirmed`, then treats every other `PlatformWalletError` as an ordinary failure. The Kotlin equivalent at `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/dashpay/ContactRequestOutcomes.kt:116-128` has the same issue, and the shielded send helpers at `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/ViewModels/SendViewModel.swift:849-857` and `packages/kotlin-sdk/KotlinExampleApp/app/src/main/java/org/dashfoundation/example/ui/wallet/SendTransactionScreen.kt:804-813` enumerate subclasses instead of reading native metadata. A shared result code can carry a Rust-classified `MaybeSent` or `LockHeld` result that is not represented by the selected subclass, causing the UI to present an uncertain payment as a normal failure and permit a fresh submission. These application consumers must honor `PlatformWalletError.delivery`/`isRetryable` and `DashSdkError.delivery`/`isRetryable` first; retain only application-specific states such as contact-request holds after checking the native class.
In `packages/rs-platform-wallet-ffi/src/shielded_send.rs`:
- [BLOCKING] packages/rs-platform-wallet-ffi/src/shielded_send.rs:762-766: FFI panic guards still decide the payment-delivery policy
`catch_spend_panic` and `catch_funding_panic` pass `Some((PaymentDelivery::MaybeSent, false))` directly into the FFI panic guard. Because the guard wraps the entire export body, a panic during argument decoding, wallet/coordinator lookup, or another pre-dispatch step is classified by the FFI layer rather than by the Rust wallet operation. This leaves payment-delivery and retry policy in an FFI crate, contrary to the PR's ownership boundary, and future changes to the export lifecycle can silently make the hard-coded tuple incorrect. The wallet operation should provide an explicit disposition to the boundary, or an FFI-only panic should remain `Unknown` and fail closed; the FFI wrapper should only marshal that disposition.
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.
- Kotlin does not persist the recorded shielded recipient for asset-lock recovery — Kotlin's
AssetLockEntity, persistence bridge, and persistence handler do not carry the optional shielded recipient sidecar that Swift persists. After a restart, the Kotlin shielded resume screen allows a new recipient to be selected for a held lock, weakening recipient-mismatch protection. This is an adjacent pre-existing recovery issue rather than a defect introduced by the payment-class transport.- Follow-up: Open a follow-up PR adding the Kotlin asset-lock sidecar schema, bridge callbacks, persistence handling, migration coverage, and recipient-bound resume validation.
|
Addressed in this push (head 345ef0e):
|
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; 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
The head has two blocking Swift regressions: the new associated value on PlatformWalletError leaves existing enum-case callbacks and pattern matches uncompilable, and the generic Swift error adapter can override Rust-owned retry decisions with message-based inference. Rust also omits transient PersisterFlush failures from its retry policy, causing a real safe-retry path to be reported as non-retryable. The Swift SDK CI check fails on this head; Rust and Kotlin checks pass.
A pattern across this PR's review rounds
This is review round 5, and the PR has drawn 8 blocking findings so far. 8 of them share 2 underlying causes. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.
1. Payment policy is still duplicated across the boundary (1 new in this round, 7 earlier finding(s))
PlatformWalletError.payment_delivery() and is_retryable() are intended to be the source of truth, but FFI error folding, panic guards, Kotlin, Swift, and application helpers still contain their own decisions or fallbacks. Each fix repairs one route while leaving another result-code, panic, alternate-payload, or generic-error route that can classify the same payment differently, so the next review finds another copy of the policy.
In this round: Swift's generic error adapter still derives retryability from error types and messages
2. Host error construction was not migrated as one API (1 new in this round, 2 earlier finding(s))
Adding the payment class to PlatformWalletError changed both its associated-value shape and the required metadata carried through alternate construction paths. Direct Swift callbacks, enum patterns, and the Kotlin shielded-create payload were treated as isolated call sites rather than one compatibility boundary, which causes both compilation failures and loss of Rust's classification in different consumers.
In this round: Swift enum-case arity change leaves existing FFI helper call sites uncompilable
Suggested decision (redesign the component): Redesign the platform-wallet error propagation component around one typed payment disposition containing delivery, retryability, and the held outpoint. Every wallet operation should produce that disposition before crossing FFI; FFI panic and argument-validation paths with no wallet error should remain explicitly Unknown, while FFI, JNI, Swift, Kotlin, and applications only marshal and read it. Do not continue adding per-code or per-call-site policy patches until this single boundary is enforced.
🔴 3 blocking
2 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Swift enum-case arity change leaves existing FFI helper call sites uncompilable
packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift:336-430
Adding payment: PlatformPaymentClass? = nil changes PlatformWalletError.invalidParameter from a one-argument constructor to a two-argument function when referenced as a callback. The seven withDecisionProposalCString calls in this file still pass PlatformWalletError.invalidParameter directly, although the callback accepts (String) -> PlatformWalletError; Swift therefore reports conversion errors and the Swift SDK build fails. The same associated-value arity change also requires updating the unchanged transactionBroadcastUnconfirmed(_) catch patterns in DocumentsView.swift and TransitionDetailView.swift, plus the one-value invalidParameter pattern in MultipleChoiceProposalMarshallingTests.swift. Wrap each callback in a one-argument closure and match both associated values at the affected patterns.
invalid: { PlatformWalletError.invalidParameter($0) }
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality, security-auditor)
🔴 Blocking: Swift's generic error adapter still derives retryability from error types and messages
packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift:341-362
PlatformWalletError now carries Rust's payment class and retry decision, but this adapter hard-codes false only for transactionBroadcastUnconfirmed and routes every other PlatformWalletError through ErrorCategorizer and ErrorRecovery.isRetryable. A Rust-classified MaybeSent error can contain words such as network or timeout and become retryable in UserFacingError, while a Rust-approved transient NotSent error can be suppressed by a storage or unknown category. BaseViewModel.isErrorRetryable exposes this value to the application, so the mismatch can either invite a second payment or hide a safe retry. When the error carries a native payment class, the adapter must use walletError.isRetryable and must keep unclassified Swift-created errors non-retryable; generic category inference may remain only for presentation.
Raised on code unchanged since the last review, and confirmed by an independent pass: A result-built PlatformWalletError.shieldedSpendUnconfirmed("timeout", payment: .maybeSent) is categorized as .timeout because ErrorCategorizer examines the case description, so toUserFacingError returns UserFacingError.isRetryable == true even though Rust supplied retryable == false for MaybeSent. BaseViewModel exposes that value as isErrorRetryable, allowing a resubmission while the original payment may already have been sent; conversely, a Rust-approved NotSent retry can be suppressed by a non-retryable inferred category.
source: gpt-6.1-sol (phase2-reviewer: general)
Still open from earlier rounds (1)
- 🔴 Blocking: Payment-delivery tests do not cover most classified variants —
packages/rs-platform-wallet/src/error.rs:1546-1557(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, intricate cross-language change that changes wallet payment-delivery classification and retry/resume behavior around asset locks, funds movement, and coin selection in packages/rs-platform-wallet/src/error.rs and related FFI/JNI/Swift/Kotlin boundaries. - 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 (
730a1527): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 confirmed - 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
Several findings on this PR share an underlying cause (the review's "pattern" section): Payment policy is still duplicated across the boundary; Host error construction was not migrated as one API. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Redesign the platform-wallet error propagation component around one typed payment disposition containing delivery, retryability, and the held outpoint. Every wallet operation should produce that disposition before crossing FFI; FFI panic and argument-validation paths with no wallet error should remain explicitly Unknown, while FFI, JNI, Swift, Kotlin, and applications only marshal and read it. Do not continue adding per-code or per-call-site policy patches until this single boundary is enforced. If that decision is not yours to make, say so to the PR's author or maintainer.
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/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Voting/MultipleChoiceProposal.swift:336-430: Swift enum-case arity change leaves existing FFI helper call sites uncompilable
Adding `payment: PlatformPaymentClass? = nil` changes `PlatformWalletError.invalidParameter` from a one-argument constructor to a two-argument function when referenced as a callback. The seven `withDecisionProposalCString` calls in this file still pass `PlatformWalletError.invalidParameter` directly, although the callback accepts `(String) -> PlatformWalletError`; Swift therefore reports conversion errors and the Swift SDK build fails. The same associated-value arity change also requires updating the unchanged `transactionBroadcastUnconfirmed(_)` catch patterns in `DocumentsView.swift` and `TransitionDetailView.swift`, plus the one-value `invalidParameter` pattern in `MultipleChoiceProposalMarshallingTests.swift`. Wrap each callback in a one-argument closure and match both associated values at the affected patterns.
In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift:341-362: Swift's generic error adapter still derives retryability from error types and messages
`PlatformWalletError` now carries Rust's payment class and retry decision, but this adapter hard-codes `false` only for `transactionBroadcastUnconfirmed` and routes every other `PlatformWalletError` through `ErrorCategorizer` and `ErrorRecovery.isRetryable`. A Rust-classified `MaybeSent` error can contain words such as `network` or `timeout` and become retryable in `UserFacingError`, while a Rust-approved transient `NotSent` error can be suppressed by a storage or unknown category. `BaseViewModel.isErrorRetryable` exposes this value to the application, so the mismatch can either invite a second payment or hide a safe retry. When the error carries a native payment class, the adapter must use `walletError.isRetryable` and must keep unclassified Swift-created errors non-retryable; generic category inference may remain only for presentation.
_Raised on code unchanged since the last review, and confirmed by an independent pass: A result-built PlatformWalletError.shieldedSpendUnconfirmed("timeout", payment: .maybeSent) is categorized as .timeout because ErrorCategorizer examines the case description, so toUserFacingError returns UserFacingError.isRetryable == true even though Rust supplied retryable == false for MaybeSent. BaseViewModel exposes that value as isErrorRetryable, allowing a resubmission while the original payment may already have been sent; conversely, a Rust-approved NotSent retry can be suppressed by a non-retryable inferred category._
In `packages/rs-platform-wallet/src/error.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/error.rs:1546-1557: Payment-delivery tests do not cover most classified variants
(carried; thread: https://github.com/dashpay/platform/pull/5928#discussion_r4578895214)
|
Round 5, at 0864058:
Rust: CI clippy set ( |
|
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
One in-scope blocking security issue remains in the Swift generic error adapter. It forwards Rust's retry flag for LockHeld failures but drops the held-lock delivery and outpoint, so generic callers can mistake a resume-only retry for permission to submit a new payment; no CodeRabbit findings were present, and CI shows no failed code checks, with Rust workspace tests still in progress.
A pattern across this PR's review rounds
This is review round 6, and the PR has drawn 9 blocking findings so far. 8 of them share one underlying cause. They are listed with the other findings as usual; fixing the cause is likely to be cheaper than fixing each case.
1. The host error path still carries a retry bit instead of the payment disposition (1 new in this round, 10 earlier finding(s))
Rust now knows a coupled disposition—delivery, retryability, and the held outpoint—but the boundary exposes and reconstructs those pieces independently. PlatformWalletError carries PlatformPaymentClass, while ErrorCategorizer.toUserFacingError copies only isRetryable into UserFacingError; a LockHeld retry therefore reaches generic callers without the outpoint and can be mistaken for permission to run the original payment again. Earlier fixes repair individual FFI, JNI, Swift, Kotlin, and application routes, but the absence of one end-to-end typed contract leaves another adapter to drop or reinterpret a field.
In this round: Swift's generic user-facing error drops LockHeld semantics while exposing retry=true
Suggested decision (redesign the component): Redesign the host error-propagation component around one typed payment disposition carried from Rust through FFI/JNI/Swift/Kotlin and into UserFacingError, including delivery, retryability, and the held outpoint. Generic retry handling must preserve that disposition, and LockHeld must dispatch only to the named-lock resume path rather than rerunning the original payment. Do not add another per-layer conversion or retry-bit fallback until this contract is enforced.
🔴 1 blocking
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) — This is a large, intricate cross-language change to platform-wallet payment failure handling that directly controls retry, asset-lock resumption, and whether funds may be sent or funded again. - 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.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
Several findings on this PR share an underlying cause (the review's "pattern" section): The host error path still carries a retry bit instead of the payment disposition. When you fix the findings below, fix the cause, not only the reported case. The review suggests (redesign the component): Redesign the host error-propagation component around one typed payment disposition carried from Rust through FFI/JNI/Swift/Kotlin and into UserFacingError, including delivery, retryability, and the held outpoint. Generic retry handling must preserve that disposition, and LockHeld must dispatch only to the named-lock resume path rather than rerunning the original payment. Do not add another per-layer conversion or retry-bit fallback until this contract is enforced. If that decision is not yours to make, say so to the PR's author or maintainer.
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/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift:357-360: Swift's generic user-facing error drops LockHeld semantics while exposing retry=true
`ErrorCategorizer.toUserFacingError` copies `PlatformWalletError.isRetryable` into `UserFacingError`, but `UserFacingError` carries neither `PlatformPaymentDelivery` nor the held asset-lock outpoint. Rust sets `isRetryable == true` for `LockHeld` only because the retry must resume the named lock; it must never create or fund a new payment. The generic adapter therefore exposes `UserFacingError.isRetryable == true` without the information needed to perform the required resume, and a caller such as a generic retry handler can rerun the original payment operation, potentially creating a second payment while the first lock remains resumable. Preserve the payment class and outpoint through this adapter, or fail closed for `LockHeld` until a resume-specific API is available.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
The ChainLock fallback's error is wrapped as unconfirmed, which hid Platform's consumed-outpoint verdict from the adoption check, so a claim whose InstantSend primary had landed reported a failure instead of its identity. The check now reads the verdict through the wrapper and keeps the wrapper when nothing is adopted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ror to the hosts Second part of the split of #5928, on top of the payment class itself. The remaining wallet paths now set their class (DPNS and the marketplace, contact requests, credit and token shielded spends and plans, shielded tips, the shielded seed batch and the wallet drain, masternode withdrawals), and every FFI result carries Rust's class: `payment_delivery`, `retryable` and the held asset lock's outpoint on `PlatformWalletFFIResult`, set from the wallet error by the blanket conversion and every result mapper, never inferred from the code. A panic in a payment export is classed as possibly sent. ERROR_CODE_REGISTRY.md documents the class per code. Swift and Kotlin read it in the next two PRs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Third part of the split of #5928. `PlatformWalletError` carries the FFI result's `PlatformPaymentClass` (delivery, retry, and the held asset lock under `LockHeld`) on every case, read from the result and never derived from the code; texts and recovery suggestions follow it, and a guard that throws after a successful FFI call carries a class too. SwiftExampleApp presents a payment failure by its class: it holds a payment's slot unless nothing was sent, names a held voucher or lock, and releases a hold only once the user reconciled it. BREAKING CHANGE: `PlatformWalletError` cases gain a `payment:` field. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Last part of the split of #5928. The JNI bridge carries the FFI result's payment class into `DashSDKException`, including the error beside a wallet drain's packed outcome, and `DashSdkError.PlatformWallet` exposes `delivery`, `isRetryable` and `heldAssetLock` from it; `PaymentRecovery` reads it for hosts, and texts follow it. KotlinExampleApp's payment screens follow the class: a payment's slot is held unless nothing was sent, a held invitation voucher is reclaimed and named, and a reconciled hold is released only after confirmation. The SDK parity manifest gets the `errors.payment_class` capability (Swift and Kotlin). BREAKING CHANGE: `DashSDKException` gains the payment class fields. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Your move: coderabbitai left review threads unresolved; resolve them; thepastaclaw left review threads unresolved; resolve them. |
|
Your move: coderabbitai left review threads unresolved; resolve them; thepastaclaw left review threads unresolved; resolve them. |
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
GitHub still shows changes requested by this bot (review of
3b8e0079). Nothing on this head blocks except the disputed finding(s) below, which are left to the maintainers: a maintainer can dismiss that earlier review if they agree it no longer applies.
Nothing blocks: no blocking finding stands on this head.
Not counted: 1 disputed blocking finding(s) left to maintainers.
New on this head: This head only updates invitation-claim adoption so a consumed-outpoint verdict remains visible through the unconfirmed ChainLock fallback wrapper, and adds regression coverage for adoption and non-adoption outcomes. CI has no reported failures; Rust workspace tests and review-policy checks are still in progress.
🔴 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: 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) — This large and intricate diff changes wallet funding, asset-lock tracking, coin-selection flows, payment dispatch classification, and recovery behavior in functions such as AssetLockManager::with_funded_lock and shielded funding, directly affecting funds movement. - 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.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. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
Not approved: 1 blocking finding(s) are disputed and left to the maintainers.
|
Bots are done — your move: post |
Superseded: the blocking finding was fixed in 81671e6 and thepastaclaw confirmed it resolved at that head.
|
/self-reviewed |
|
Ready for review — |
HashEngineering
left a comment
There was a problem hiding this comment.
Re-reviewed after the split at 81671e6. I compared this stack with what I approved at 5f5b560: the only differences are the five new commits and v5.2-dev drift, so nothing was lost or added. The invitation-claim commits look right to me and don't open a double-claim path. Locally, platform-wallet 2990/2990, dash-sdk invitation tests 95/95 and platform-wallet-ffi 641 passed; clippy is clean.
Worth a small follow-up commit:
rs-sdk/src/platform/dashpay/invitation.rs:1507-1509: 3b8e007 wraps every ChainLock-fallback error as unconfirmed, butkeys_taken_on_broadcast(:1205) readsconsensus_error(), which returnsNonethrough that wrapper (rs-sdk/src/error.rs:327). A fallback refused with 40207 is therefore reported as code 20 instead ofKeysAlreadyRegistered(63). The class isMaybeSenteither way, so only the diagnostic is lost. Unwrapping before the check, as 81671e6 does for the consumed check, would fix it, and there is no test for this path yet.invitation.rs:1591-1598reports_consumed_out_pointonly looks through an outer unconfirmed wrapper. An unconfirmed error nested insideNoAvailableAddressesToRetrywouldn't be adopted. I haven't confirmed the retry layer produces that shape.- Stale docs:
submit_claim_with_chain_lock_fallbackstill says fallback errors propagate asInvitationError::Sdk.platform_wallet.rs:2394-2401promises a zero-amount transfer arrives asRefusedBeforeDispatch, but that wrapping only lands in #6379.
PR text:
- Breaking Changes lists items that are in #6379–#6381 rather than here: retry over the FFI, Swift/Kotlin timeout retry, the Kotlin
isRetryableoverrides,token_pool_spend_preview_for, and the code-35 host behaviour. - The title needs
!for theInvitationError/AssetLockNotChainLockedshape changes. dash-sdk --libhas 1086 tests, not 1085, and the JNI count doesn't apply to this part.
|
Policy satisfied — this can merge. |
#5928 was squashed into v5.2-dev, so error.rs and shielded_send.rs keep this branch's side. map_tip_send_result reads through the payment-class wrapper, as the other mappers do, so a wrapped refusal keeps its code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t class #5928 added matches without a wildcard arm over PlatformWalletError. WithdrawalAmountOutOfRange is raised while the withdrawal is planned, so it is NotSent, not retryable with the same amount, and does not refuse the resume of a tracked asset lock, like its shielded sibling. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…latform-wallet-top-up-someone-elses-identity-fr Resolves the conflicts with #5928 (payment delivery classes): - payment_delivery, is_retryable, refuses_resume and the variant table classify this PR's asset-lock variants: AssetLockIdentityRecipientMismatch and AssetLockIdentityNotLoaded hold the lock (LockHeld), as AssetLockRecipientMismatch does; AssetLockRecipientUnknown and AssetLockAbandonedBeforeSend are NotSent and refuse a resume; AssetLockConsumptionUnknown is MaybeSent. - The post-acceptance conversion to TransactionBroadcastUnconfirmed runs inside the funded-lock seam, and only once the wallet or row is gone, so a failed read of a still-tracked lock keeps naming it as held. - tracked_resume_metadata keeps returning TrackedResumeMetadata, which carries the shielded recipient the upstream tuple added. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Issue being fixed or feature implemented
Part of #5926. Whether a failed payment may have left the wallet was decided by every host from lists of error codes (Swift, Kotlin
isRetryable, the apps), with different defaults per platform, while rs-platform-wallet already knows it and kept it crate-private (BroadcastDelivery). Rust now owns the answer; FFI, JNI, Swift and Kotlin only carry it.Stack
This is part 1 of 4 of #5928, split for review (about 3–5k lines each). Each part builds and tests on its own base and is safe to merge into
v5.2-devalone; merge them in order.What was done?
PaymentDelivery { NotSent, MaybeSent, LockHeld(OutPoint) },PlatformWalletError::payment_delivery()andheld_asset_lock() -> Option<OutPoint>(theLockHeldoutpoint, read frompayment_delivery). The match is exhaustive (no_arm), so a new variant cannot ship without a class. The class of an SDK failure (sdk_payment_delivery) names everydash_sdk::Errorvariant too, so a new pre-send SDK refusal cannot fall intoMaybeSentsilently.TransactionBroadcast(a Core rejection),ShieldedBroadcastFailed, signer key unavailable,ProtocolVersionNotActive.InputMidBroadcast,PrivateContactRequestPending,ShieldedIdentityDebitPending, the recovery refusals): nothing of this request left the wallet.Sdkerrors, and the asset-lock errors that name no lock this payment can resume (AssetLockAlreadyConsumed,AssetLockTooManyInputs,AssetLockProofWait,AssetLockExpired,AssetLockNotChainLocked).FinalityTimeout,AssetLockInputContested,AssetLockRecipientMismatch(resumed with the recorded recipient). The host resumes the named lock and never funds a new one.PlatformWalletErrorvariant (130), guarded by an exhaustive ordinal match, so a wrong class in any arm fails.AssetLockManager::with_funded_lock, which names the lock as held while it is tracked and resumable and reports MaybeSent once it is consumed or consumption-unknown (handoff_failure). A multi-step payment (DPNS after its preorder, the seed pool after its first batch) is MaybeSent after its first dispatch (after_dispatch()). The FFI never decides a class: an output that cannot be handed back after a successful call takes the wallet's class (handoff_failurefor a lock, MaybeSent otherwise), and every Core payment export's refusal carries one.is_retryable()states a decision for every variant, with no wildcard arm.AssetLockManager::with_funded_lock) and the flows built on it: identity registration, the external identity top-up from addresses, invitation create and claim, the Platform-address and shielded fundings from an asset lock (wallet drain included). The remaining paths (DPNS, contact requests, shielded spends and tips, the seed pool, masternode withdrawals) follow in part 2.without_payment_class), so hosts keep the codes they get today until part 2 carries the class.NotSent(as its operation records);RefusedBeforeDispatchis never retryable and its docs say so; the resume-refusal check names every variant; an invitation claim whose ChainLock fallback fails after a possibly sent InstantSend claim stays unconfirmed.How Has This Been Tested?
cargo test -p platform-wallet --all-features --lib2990,-p platform-wallet-ffi --lib641,-p rs-unified-sdk-jni --lib154,-p dash-sdk --lib --all-features1085: all green.cargo clippy -p platform-wallet -p platform-wallet-ffi -p rs-unified-sdk-jni -p dash-sdk --all-features --all-targets -- -D warningsclean;cargo fmt --all.Breaking Changes
dash_sdk::platform::dashpay::invitation::InvitationError::NotChainLockedandPlatformWalletError::AssetLockNotChainLockedare struct variants{ message, after_broadcast }(were a tuple of the message), andInvitationError::AlreadyClaimedgainsafter_broadcast. Code 66 is NotSent and retryable only before the claim was sent (funding transaction not found, ChainLock invitation not chain-locked yet). A claim sent with its islock proof and refused (stale islock, input cap, or size, which a node and the SDK's own check report alike) is MaybeSent, not retryable, and its message says to check the original claim first. An already-claimed invitation (codes 24, 64) is NotSent when the preflight found it, MaybeSent after a submission; neither is retryable.shielded_transfer_to(and, for the shielded tip throughtransfer_once_claimed, of itsonce_claimedcheck) isNotSent. One whose variant is otherwise classed possibly sent (a zero amount, an invalid recipient, a tip source that no longer stands) arrives wrapped inPlatformWalletError::RefusedBeforeDispatch: match the diagnostic onerror.dispatched_source()and read delivery and retry from the outer error (payment_delivery(),is_retryable()). A later failure keeps its own class, even one before the build: a failed recorded-anchor fetch is an SDK error, classedMaybeSent. The same wrapping applies toPlatformWallet::shielded_plan_spend(a zero amount, an inactive spend kind, a network version that does not support the spend) and toshielded_fund_from_asset_lockrefusing an oversized shield batch on a fresh lock. The module-level planners (wallet::shielded::operations::plan_spend,note_selection::plan_spend) keep returning the bare error with its conservative class; the classed entry point isshielded_plan_spend. The token pool spend preview follows the same split:token_pool_spend_preview_for(and soShieldedTokenPurchaser::preview_spendandplatform_wallet_manager_shielded_token_spend_preview) wraps a zero amount or a failed store read inRefusedBeforeDispatch(NotSent), whiletoken_pool_spend_previewkeeps the bare error.PlatformWalletError::is_retryable()sits next topayment_delivery(), and its answer crosses asretryable. Hosts only read it.InputMidBroadcast,PrivateContactRequestPending,ShieldedIdentityDebitPendingand the recovery refusals are NotSent and not retryable (were MaybeSent). An unverified Swift or Kotlin broadcast timeout is not retryable.ReservationTokenConsumed(35) is MaybeSent: an earlier broadcast of the token may have sent the payment, so a host that took it as not broadcast and released the reservation must stop doing so. Kotlin's per-classisRetryableoverrides (e.g. codes 58, 80) are gone: the native flag decides, and Rust marks those two retryable.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull request🤖 Generated with Claude Code
PR Hygiene ·
81671e6rs-platform-wallet-ffi(packages/rs-platform-wallet-ffi/src/error.rs,packages/rs-platform-wallet-ffi/src/shielded_send.rs,packages/rs-platform-wallet-ffi/src/shielded_tip.rsand 1 more) — approved by HashEngineering, llbartekllrs-platform-wallet(packages/rs-platform-wallet/src/broadcaster.rs,packages/rs-platform-wallet/src/error.rs,packages/rs-platform-wallet/src/lib.rsand 17 more) — approved by HashEngineering, llbartekllrust-sdk(packages/rs-sdk/src/platform/dashpay/invitation.rs) — approved by lklimekWhen 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