Repository navigation
fix(utxo): return 409 ACCOUNT_MIRROR_BOX_NOT_SPENDABLE again, not a misleading 400 - #8468
Merged
Merged
Conversation
…isleading 400 Since #8395, account-mirror boxes are excluded inside get_coin_select_candidates() before candidate bounding, so the mirror_candidate_ids branch in /utxo/transfer can never fire. A sender whose funds are mirror-locked got 400 "Insufficient UTXO balance" while the same response reported balance_nrtc >= requested_nrtc. On a failed selection, decide from wallet totals: if the spendable (non-mirror) funds fall short but the mirror-locked ones would cover the request, return the 409 with the box ids; otherwise the plain 400, now with spendable_nrtc. Totals are wallet-wide (SQL SUM), not the bounded candidate list, so #8395's false-409 cannot return. No state change: this only runs after coin selection has already failed. Fixes the two long-failing tests (test_utxo_dual_write_double_spend, test_utxo_transfer_spends_account_mirror) and adds a guard that a request beyond the whole wallet stays a plain 400. Full CI suite (with #8467's collection fix applied locally): 4012 passed, 0 failed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Scott <scottbphone12@gmail.com>
Contributor
|
| Metric | Value |
|---|---|
| Trust Score | 36/100 |
| Certificate ID | BCOS-afb3528b |
| Tier | L2 (not met) |
What does this mean?
The BCOS (Beacon Certified Open Source) engine scans for:
- SPDX license header compliance
- Known CVE vulnerabilities (OSV database)
- Static analysis findings (Semgrep)
- SBOM completeness
- Dependency freshness
- Test infrastructure evidence
- Review attestation tier
BCOS v2 Engine - Free & Open Source (MIT) - Elyan Labs
Contributor
RTC RewardThis merged PR earned 5 RTC — sent to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge after #8467, which restores CI test collection. Until then this PR's
testcheck stays red for the same reason every PR's does.Problem
Since #8395, mirror boxes are filtered out inside
get_coin_select_candidates(), so themirror_candidate_idsbranch in/utxo/transferbecame dead code. A sender whose funds are mirror-locked gets:{"error": "Insufficient UTXO balance", "balance_rtc": 100.0, "requested_rtc": 99.0}The balance is higher than the request, yet the response says "insufficient". Funds were never at risk (the box is not spent), but the error is misleading, and two security tests have been failing (hidden, because CI collection was broken).
Fix
This only runs after coin selection has already failed, and it changes no state. It compares wallet-wide totals:
ACCOUNT_MIRROR_BOX_NOT_SPENDABLE: spendable (non-mirror) funds fall short, but the mirror-locked funds would cover the request.Insufficient UTXO balance: otherwise. The response now includesspendable_nrtc.The totals come from SQL
SUMover the whole wallet, not the bounded candidate list, so #8395's false-409 can't come back. Only the box IDs echoed in the 409 are capped, at 50. The code passes the repo'sfetchallguard without an annotation.Verification
test_utxo_dual_write_double_spendandtest_utxo_transfer_spends_account_mirrorfail onmainand pass here.🤖 Generated with Claude Code