Merged
Conversation
…balance (#3484) * fix: filter third-party transactions and fix receiver trimming in pending balance Three issues caused Scrypt EUR pending balances to be invisible: 1. Third-party EUR deposits (txId=null) inflated the receiver sum 2. Third-party bank_tx (instructedCurrency=null) inflated the sender count 3. filterSenderPendingList did not trim orphaned receivers when sender and receiver counts were equal — old receivers whose senders aged out of the 21-day window absorbed new unmatched senders, netting to 0 Fix: filter foreign transactions from both lists, and when counts are equal, detect senders newer than all receivers (definitely unmatched) and trim corresponding orphaned old receivers. * fix: replace sum-based Scrypt pending balance with 1:1 transaction matching The previous approach used filterSenderPendingList + sum difference to calculate pending Scrypt balances. This was fundamentally flawed: old receivers whose senders aged out of the 21-day window created false negatives, making pending transfers invisible. New approach: getUnmatchedSenders() matches each sender with a receiver 1:1 by amount and chronological order (same criteria as findSenderReceiverPair). Only truly unmatched senders contribute to the pending balance — no receiver subtraction needed. Applied to all 4 Scrypt directions (CHF/EUR × Bank→Scrypt/Scrypt→Bank), both filtered and unfiltered paths. Kraken paths unchanged. * fix: add 21-day filter on senders in getUnmatchedSenders Filter senders to the last 21 days (only recent transfers are pending) but keep all receivers available for matching (prevents orphaned receivers from aged-out senders). * fix: match CHF and EUR separately in unfiltered non-ScryptEur path Combined CHF+EUR matching could cause cross-currency matches (e.g. CHF sender 30k matching EUR receiver 30k). Match each currency separately, then combine results. * fix: replace fuzzy matching with reference-based 1:1 matching for Scrypt pending balance Replace amount+timing greedy matching in getUnmatchedSenders with exact reference matching (bankTx.remittanceInfo === exchangeTx.txId). This eliminates wrong pairings that inflated the pending balance. Additional fixes: - Remove txId filter on EUR receivers (excluded legitimate deposits) - Change status === 'ok' to status !== 'failed' on all Scrypt exchange_tx filters (pending deposits/withdrawals now count as matched) - Reduce sender window from 21 to 7 days (max transfer duration) * style: fix prettier formatting in test file
TaprootFreak
approved these changes
Mar 21, 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