bitcore-node icon indicating copy to clipboard operation
bitcore-node copied to clipboard

Received balance incorrectly includes tx change

Open STRML opened this issue 10 years ago • 3 comments

If change from a tx is sent back to the same address, it is erroneously counted in the totalReceived.

There is an issue on insight-api for this, but the bug lies here:

https://github.com/bitpay/insight-api/issues/351

Consider the massive discrepancy in total received as shown in that ticket between Insight and all other explorers.

STRML avatar Dec 16 '15 21:12 STRML

I think we're going to need some additional indexes to make querying the satoshis being spent for each input faster here (see https://github.com/bitpay/bitcore-node/pull/376#issuecomment-173338788). There could also be some benefits with caching results, so we may want to take a look at adding that, and calculating the change in that case should be simple. However, there may be pros and cons to consider there that we should be careful.

braydonf avatar Jan 21 '16 15:01 braydonf

Here is another case where we may need to lookup the previous transaction for each input to create the indexes: https://github.com/bitpay/bitcore-node/issues/397

braydonf avatar Jan 21 '16 17:01 braydonf

Looks good in 3.0. Appears we can finally do this right this time. We're going to upgrade our Testnet instances and see how it goes.

STRML avatar May 28 '16 17:05 STRML