-
Notifications
You must be signed in to change notification settings - Fork 635
Don't count change transactions in totalSpent or totalReceived. #376
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
Conversation
This puts bitcore's calculations of spent and received in line with the behavior of other block explorers. Fixes bitpay#373 and bitpay/insight-api#351.
|
Also, in general, is there a reason why var outputs;
var inputs;
async.parallel(
[
function(next) {
self.getInputs(address, opt, function(err, ins) {
inputs = ins;
next(err);
});
},
function(next) {
self.getOutputs(address, opt, function(err, outs) {
outputs = outs;
next(err);
});
}
],
function(err) {
if(err) {
return callback(err);
}could be shortened to async.parallel(
[
function(next) {
self.getInputs(address, opt, next);
},
function(next) {
self.getOutputs(address, opt, next);
}
],
function(err, results) {
if(err) {
return callback(err);
}
var inputs = results[0], outputs = results[1]; |
|
Added some new fixes for mempool transactions + corresponding tests. Also added |
|
I think we should standardize on this is some way, and clarify, especially since it's expected from other block explorers. Technically, the address is receiving the amount again, so there is unfortunate ambiguity to what "received" means (and there are others too). |
|
Right. That's why I've added the fields, which has really helped in our usage. Perhaps it makes sense to copy some of the output from a popular explorer, like Blockchain.info. But this is also something that more thorough documentation can fix. |
|
I think the best way we can handle this case is to add a value called "change", this way the values for "totalRecieved" and "totalSpent" don't need to change. And there is additional information to be able to calculate "totalRecieved" excluding change. This could also be more simply expressed as a "delta". Also we need to know the amount of satoshis that are being spent for each input to accurately calculate the change amount (not currently available and is currently expensive to query) considering a transaction such as this:
The results would be for address A:
Being able to query the amount spent for an input more efficiently for any output would also be necessary for some other optimizations for caching large address queries. However this could deoptimize syncing times and queries for single-use addresses. There may be a better solution, but may require possible more major reworking. |
|
Honestly, I think this is just more work for consumers - every other blockchain explorer API we've used discounts change transactions in the way this PR is doing it. Yeah, it'd be a major version upgrade but it is absolutely vital that it counts these transactions properly. Why would bitcore-node want to create surprise there? |
|
v2 would have been a very good time to clean up the output of the Address service and fix the change outputs. Are there not plans to do this? Failing to merge this before the rewrite will make it difficult to rebase and fix the merge errors. |
|
There currently are no plans to do this, however it's non-trivial, and I think better suited for either another service or another release. |
|
It's a shame to hear that. I consider the data emitted from the API nearly useless without proper change accounting. We've been using this patch for over a month now without issues. I am surprised to see such flippant dismissal of this work. |
|
Bitcore has decidedly non-standard behavior here (different than all major block explorers), and you closed this PR without giving us a chance to rebase or talk about what needs to be done to get it in v2? This is no way to treat contributors. Don't expect more contributions from our team. |
|
I've spawned an issue with more details here: #400 |
|
Hello @STRML Thank you for this, Is it still okay to use this on the latest release? I just want to run a free Blockchain API but this incorrect Total Receive is kinda killing me, I'd rather use a professional's solution instead of doing it myself and causing huge performance drop. |
|
@naghajani Unfortunately this needs a total rework to work on the newest version of Bitcore. |
This puts bitcore's calculations of spent and received in line with
the behavior of other block explorers.
Fixes #373 and bitpay/insight-api#351.