Merged
Conversation
Problem: - fromScryptUnfiltered and toScryptUnfiltered could be negative - These values were added to totalPlusPending without clamping - Result: totalPlus became negative, causing negative plusBalance for assets - Specifically affected Scrypt/EUR (Asset 401) with -201,499 EUR plusBalance Root Cause: - Filtered versions (fromScrypt, toScrypt) were clamped to 0 if negative - Unfiltered versions were NOT clamped, causing negative plus balances - When useUnfilteredTx=true, negative unfiltered values corrupted totalPlus Fix: - Changed fromScryptUnfiltered and toScryptUnfiltered from const to let - Added clamping logic to set negative unfiltered values to 0 - Log errors when unfiltered values are negative for debugging - Prevents negative plus balances while maintaining error visibility Impact: - Fixes critical bug where Scrypt assets could have negative plus balances - Prevents plusBalanceChf from being stored as NULL in financial logs - Maintains consistency with existing filtered value clamping logic
…3332) Previous Fix (PR #3330): - Clamped only fromScryptUnfiltered and toScryptUnfiltered individually - Left fromKrakenUnfiltered and toKrakenUnfiltered unclamped - Incomplete protection against negative plus balances This Fix: - Removed individual unfiltered component clamping - Added single clamp on totalPlusPending after calculation - Covers ALL negative sources: Kraken, Scrypt, and future exchanges - More robust and maintainable Rationale: - Simpler: One clamp instead of multiple - Complete: Catches negative values from any component - Better logging: Shows all component values when totalPlusPending is negative - Semantically correct: "Total pending plus balance cannot be negative" The filtered component clamps (fromKraken, toKraken, fromScrypt, toScrypt) remain in place for consistency and detailed error reporting.
TaprootFreak
approved these changes
Mar 3, 2026
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.
Automatic Release PR
This PR was automatically created after changes were pushed to develop.
Commits: 1 new commit(s)
Checklist