- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 69
 
fix: correct amount calculation for self-transfer transactions in BTC… #890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
fix: correct amount calculation for self-transfer transactions in BTC… #890
Conversation
| 
           The latest updates on your projects. Learn more about Vercel for GitHub. 
  | 
    
| 
           Deployed to https://msg-adamant-pr-890.surge.sh 🚀  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test failed.
Amount is incorrect.
See this transaction: https://www.blockchain.com/explorer/transactions/btc/d9dc71624543a28df63c2a10455f3b35fe78b4f4fb9a8ba271a07e750019b572
First output is the amount.
The last one is receiving the change.
| 
           Connected issue: Wrong transfer direction and amount.  
See this transaction:  
It's outcome transfer, not income.  | 
    
| 
           Another issue  | 
    






fix: correct amount calculation for self-transfer transactions in BTC, DASH, and DOGE and changes for transaction icon and text
Description
Fixed a bug where transactions sent to the user's own address displayed amount: 0 in the transaction list. Also change and add new color styles for transaction direction icon and amount text.
Changes
1. Self-transfer amount calculation fix
Root cause:
The
normalizeTransaction()function in BTC/DASH/DOGE indexers incorrectly calculated the amount for self-transfer transactions. When a user sent funds to their own address, the transaction was classified as "outgoing" (direction = 'from'), but the amount calculation logic expected it to behave like an "incoming" transaction. This resulted in all outputs being excluded from the sum, producingamount = 0.Fix applied:
isSelfTransferdetection innormalizeTransaction()src/lib/nodes/btc-indexer/utils.tssrc/lib/nodes/dash/utils.tssrc/lib/nodes/doge-indexer/utils.ts2. Changes color in transaction text and icon
Added visual distinction for transaction types through color-coded plane icons:
rgba(255, 255, 255, 0.7))Implementation:
TransactionListItem.vueto applydirectionClassto the prepend icon3. Fixed duplicate senders bug
Root cause:
When a transaction had multiple inputs (UTXOs) from the same address, the
sendersarray contained duplicate addresses. This caused the UI to incorrectly display "Me and 1 more address" instead of just "Me" for the sender.Fix applied:
new Set()for bothsendersandrecipientsarrays4. Improved self-transfer detection logic
Root cause:
Previous implementation used
.includes()to detect self-transfers, which incorrectly identified transactions as self-transfers even when only some (not all) addresses matched the owner.Fix applied:
.includes()to.every()5. Added comprehensive unit tests
Added unit tests for all three cryptocurrencies to prevent regression:
src/lib/nodes/btc-indexer/utils.spec.tssrc/lib/nodes/dash/utils.spec.tssrc/lib/nodes/doge-indexer/utils.spec.tsTest coverage:
Impact
Related issue
Closes 889
External links (optional)
N/A
Screenshots or videos (optional)
Breaking changes
No breaking changes.
How to test
Prerequisites:
Test steps:
Self-transfer amount calculation fix
Create self-transfer transaction:
Verify transaction display:
Changes color in transaction text and icon
Verify incoming transaction colors:
Verify outgoing transaction colors:
Verify self-transfer transaction colors:
rgba(255, 255, 255, 0.7))Test theme switching:
Duplicate senders fix
Create transaction with multiple UTXOs:
Verify sender display:
Run unit tests
Checklist