mempool / electrs

An efficient re-implementation of Electrum Server in Rust
MIT License
74 stars 35 forks source link

Fix summary tx ordering #94

Closed mononaut closed 5 months ago

mononaut commented 5 months ago

(build on #93)

does not require an additional re-index after #93

This PR takes advantage of the tx_position component of the address history index to ensure that transactions returned by the .../txs/summary endpoints are also correctly ordered.

This fixes some issues with the address balance charts on mempool.space, where the total balance could spike higher than it should when the same coins are recycled through multiple transactions in the same block.

E.g, for the address bc1pn8ynw7a0fec5daqfv7h4r2hvta82dpsztcu30s4fgh2958yd7pkqnrkkjy

Before: many erroneous balance spikes, for example when the same ~4k sats is received and spent twice in the same block across four transactions, we incorrectly show the balance spiking to 8k sats because the events are out of order:

Screenshot 2024-05-13 at 6 49 08 PM

After: the balance chart is correct:

Screenshot 2024-05-13 at 6 49 20 PM
junderw commented 5 months ago

You could point this PR to junderw/order_txes_in_block and we can merge it into #93 before merging it.

junderw commented 5 months ago

Merged into #93