Repository navigation
fix(platform-wallet): report an identity balance refusal on withdrawal as insufficient credits - #5206
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 56 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository: dashpay/platform/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Final review complete — no blockers (commit bcaa0fe) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The change correctly promotes identity balance refusals for withdrawals and transfers to addresses into the existing typed InsufficientIdentityCredits error while preserving signer-key and fallback behavior. The remaining identity-to-identity and masternode withdrawal paths stringify similar refusals, but those are pre-existing adjacent paths outside this PR's explicitly stated scope.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: architecture-layering); reviewer 3: glm-5.3-flash (agent: phase1-reviewer, role: ffi-engineer); reviewer 4: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 7: gpt-6-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 8: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6-astra (agent: astra-verifier, role: final-verifier)
- Triage:
lowbygpt-6-astra(effort low) — The diff makes a small, contained error-mapping change that reuses an existing typed insufficient-credit error for two wallet operations, preserves other error fallbacks, and adds focused tests without changing funds movement, consensus rules, or the FFI ABI. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— architecture-layering (completed, effort high); agentphase1-reviewer,glm-5.3-flash— ffi-engineer (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 99% left, weekly 82% left; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 13% left, 5h 100% left) - Fresh verifier:
gpt-6-astra— final-verifier; agentastra-verifier - Phase 2 reviewers:
gpt-6-astra— general (completed, effort medium); agentphase2-reviewer,gpt-6-astra— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6-astra— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort medium); agentphase2-reviewer
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.
- Other identity-funded credit paths still stringify balance refusals — The identity-to-identity credit transfer path in transfer.rs and the masternode withdrawal path still route IdentityInsufficientBalanceError through preserve_signer_key_unavailable_or, producing InvalidIdentityData prose instead of the typed InsufficientIdentityCredits result. These paths are unchanged by this PR and are outside the stated withdrawal and transfer-to-addresses scope, but a follow-up could route them through the new centralized promotion helper for consistent host-facing errors.
- Follow-up: Track a separate maintainer-requested change to apply promote_identity_insufficient_balance_or to transfer_credits_with_external_signer and execute_masternode_withdrawal.
- Sibling identity→identity credit transfer still stringifies the same balance refusal this PR promotes — Already covered by the consolidated out-of-scope follow-up; transfer.rs is an unchanged sibling path outside the PR's explicitly documented scope.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
… dependency - Add the new refusal string to every Localizable.strings (English in all locales until Transifex supplies translations), at the position the catalog tooling sorts it to. - Say in the doc comment that the typed branch is not reached until the SDK ships dashpay/platform#5206, as a TODO rather than a present-tense claim. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Bots are done — your move: address llbartekll left a review thread unresolved, then post |
llbartekll
left a comment
There was a problem hiding this comment.
LGTM. Promotion order (balance refusal -> signer key-unavailable -> stringify) is right, required/available match IdentityInsufficientBalanceError::new(id, balance, required_balance), and both CheckTx and wait-stream shapes are covered via consensus_error_of. No ABI change; Swift already decodes code 39.
Non-blocking follow-up: the plain identity -> identity credit transfer (wallet/identity/network/transfer.rs:116) still goes through preserve_signer_key_unavailable_or and stringifies into InvalidIdentityData, while Platform emits the same IdentityInsufficientBalanceError for IdentityCreditTransfer (identity_credit_transfer/state/v0 + its estimated-fee validation). Swapping it to promote_identity_insufficient_balance_or would make all three credit-moving paths consistent; fine as a separate PR.
The red Kotlin SDK build + tests check is a runner issue (checkdir error: cannot create cmdline-tools while unpacking the Android SDK), unrelated to this change.
…l as insufficient credits
Platform refuses an identity credit withdrawal or credit transfer to
addresses with IdentityInsufficientBalanceError when the balance cannot
cover the amount plus the transition's minimum fee. Both wallet paths
stringified it into InvalidIdentityData ("Failed to withdraw credits:
Protocol error: Insufficient identity <id> balance <n> required <n>"),
so hosts could only show the raw protocol text.
Promote it to the typed InsufficientIdentityCredits (FFI code 39, with
Platform's required/available figures) the way the DPNS marketplace
already does, through a shared promote_identity_insufficient_balance
helper that the document-trade promotion now reuses.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
96c9109 to
7a77f6c
Compare
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-10-02T10:21:48.790Z |
…_identity_insufficient_balance_or Co-Authored-By: Claude Opus 5.5 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Static verification of the complete diff at bcaa0fe found no actionable in-scope defects: withdrawal and transfer-to-addresses balance refusals preserve Platform's required and available amounts through the existing code-39 JSON mapping, while signer-key-unavailable and unrelated-error handling remain intact. The added tests cover CheckTx, wait-stream, fallback, and signer-error preservation; the adjacent consistency follow-ups are pre-existing and outside the stated scope. The supplied exact-head CI snapshot reports successful Rust wallet tests, Swift SDK build/tests and frozen-schema checks, and Kotlin SDK build/tests; Rust workspace tests were skipped and PR Hygiene remains pending, with no local builds or tests run.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: gemini-3.8-flash-high (agent: phase1-reviewer, role: general); reviewer 2: gemini-3.8-flash-high (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: general); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The diff makes a small, contained error-mapping change in withdrawal and transfer paths, reuses existing typed errors without changing funds movement or the ABI, and adds focused regression tests. - Phase 1 reviewers:
gemini-3.8-flash-high— general (completed, effort high); agentphase1-reviewer,gemini-3.8-flash-high— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
gemini-3.8-flash-high— antigravity quota: weekly 51% left, 5h 82% left - Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); 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.
- Identity-to-identity credit transfer in
transfer.rsdoes not promoteIdentityInsufficientBalanceError— Outside scope — transfer.rs:111-121 still preserves signer-key-unavailable errors and stringifies other failures in transfer_credits_with_external_signer, but the identical mapping exists at the PR base. The stated goal explicitly covers identity withdrawals and transfers to addresses, not identity-to-identity transfers. Extending typed reporting to this sibling operation is routine adjacent consistency work, not an exceptional follow-up to retain.- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
- Promote IdentityInsufficientBalanceError in identity-to-identity transfers and masternode withdrawals — Outside scope — transfer.rs:115-120 and masternode_withdrawal.rs:456-460 use preserve_signer_key_unavailable_or with an InvalidIdentityData fallback at both base and head. Neither path is changed or newly relied upon by this PR, whose description specifically targets the ordinary identity withdrawal and transfer-to-addresses callers. Broader adoption of the helper is routine adjacent improvement and does not warrant expanding this review or retaining an exceptional follow-up.
- Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Ready for review — |
|
Policy satisfied — this can merge. |
Resolves the error.rs conflict with #5206 by keeping both sides: this branch's DASH-amount helpers for CoreFundsAwaitingNetwork and #5206's identity_insufficient_balance_tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pt it Max from Identity to Transparent held back 0.002 DASH, a reserve borrowed from identity funding (the opposite direction, where it must stay small). Platform checks an IdentityCreditWithdrawal against amount + 0.004 DASH, so every Max was refused at Confirm with the raw protocol error. The reserve is now owned by the withdrawal and depends on the target: - Transparent: the 0.004 DASH consensus minimum + 0.001 margin (0.005, the same the evonode withdrawal holds back). - Platform: 0.002 DASH, unchanged — its minimum is 0.000065 DASH. Max, the Continue gate and the inline validation all use it. A balance refusal that still reaches Confirm (the balance moved in between) is shown as a sentence instead of the protocol dump, once the SDK reports it typed (dashpay/platform#5206). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Issue being fixed or feature implemented
When Platform refuses an identity credit withdrawal (or a credit transfer to addresses) because the balance cannot cover the amount plus the transition's minimum fee, the wallet stringifies the consensus
IdentityInsufficientBalanceErrorintoInvalidIdentityData. The host receives only prose —Failed to withdraw credits: Protocol error: Insufficient identity <id> balance <n> required <n>— and Dash Wallet iOS shows exactly that text to the user.The DPNS marketplace already promotes the same consensus error to the typed
InsufficientIdentityCredits(FFI code 39); the withdrawal paths never did.What was done?
rs-platform-wallet/src/error.rs: newpromote_identity_insufficient_balance(+_orowned-error wrapper, which then falls back topreserve_signer_key_unavailable_or).promote_document_trade_errorreuses it for itsIdentityInsufficientBalanceErrorarm.wallet/identity/network/withdrawal.rs,transfer_to_addresses.rs: map SDK errors throughpromote_identity_insufficient_balance_or, so a balance refusal surfaces asPlatformWalletError::InsufficientIdentityCredits { required, available }(Platform's own figures). Every other error keeps its existing mapping.rs-platform-wallet-ffi/src/error.rs: code-39 registry and doc list the new emitters. No new code, no ABI change — Swift already decodes it asPlatformWalletError.insufficientIdentityCredits.How Has This Been Tested?
error::identity_insufficient_balance_tests(3): CheckTxProtocol(ConsensusError)shape, wait-streamStateTransitionBroadcastErrorshape through the_orwrapper, unrelated errors left to the fallback.cargo test -p platform-wallet --lib: 1180 passed.dd461eb8bdand ran Dash Wallet iOS against it on testnet (identity withdrawal and credit transfer to a Platform address both succeed).Breaking Changes
None for the ABI. Behavioural: a host that matched the
InvalidIdentityDatatext of a refused withdrawal now receives code 39 instead.Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
bcaa0fers-platform-wallet-ffi(packages/rs-platform-wallet-ffi/src/error.rs) — approved by llbartekllrs-platform-wallet(packages/rs-platform-wallet/src/error.rs,packages/rs-platform-wallet/src/wallet/identity/network/transfer_to_addresses.rs,packages/rs-platform-wallet/src/wallet/identity/network/withdrawal.rs) — approved by llbartekllWhen every box is checked the
PR Hygienecheck passes and this can merge.