Skip to content

Release: develop -> main#3331

Merged
TaprootFreak merged 2 commits intomainfrom
develop
Mar 3, 2026
Merged

Release: develop -> main#3331
TaprootFreak merged 2 commits intomainfrom
develop

Conversation

@github-actions
Copy link

@github-actions github-actions bot commented Mar 3, 2026

Automatic Release PR

This PR was automatically created after changes were pushed to develop.

Commits: 1 new commit(s)

Checklist

  • Review all changes
  • Verify CI passes
  • Approve and merge when ready for production

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 TaprootFreak merged commit 8bd8ce8 into main Mar 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant