vertcoin-project / blockchain-indexer

A C++ based indexer for blockfiles that works on Bitcoin and its derivatives https://blkidx.org/
MIT License
10 stars 8 forks source link

Wrong unconfirmedBalance on addressBalance #2

Open gertjaap opened 6 years ago

gertjaap commented 6 years ago

I have an issue with the new addressBalance details route:

https://vtc.blkidx.org/addressBalance/Vg8APdm2BhFbaZuTsXnG8Ny66k1YfnvurQ?details=1

{
"balance":866630899,
"txCount":188,
"unconfirmedBalance":866630899,
"unconfirmedTxCount":0
}

It gives me that all my VTCs are unconfirmed even though, just my last transaction of 2979020 is unconfirmed

gertjaap commented 6 years ago

https://github.com/gertjaap/blockchain-indexer/commit/7b41d1c53510712a717bc9af815afd4ab155ff5a?diff=split#diff-4881310bed00446083e365942f29d5ecR237

I can see why, it's adding to the unconfirmedBalance if the output isn't spent..

gertjaap commented 6 years ago

unconfirmedBalance would mean: Balance including unconfirmed received or spent amounts. Only the balance of unconfirmed transactions is worthless and could be negative. Makes no sense to me, so i think this is correct.

gertjaap commented 6 years ago

What I'm trying to say is that Balance must include the total Balance for that address, Confirmed + Unconfirmed. I want to know what the unconfirmed amount is because that sum cannot be spent yet.

Currently my Vertcoin Desktop wallet shows the following:

image

But the API call I shared in my original post has this:

{
  "balance": 891945724,
  "txCount": 196,
  "unconfirmedBalance": 891945724,
  "unconfirmedTxCount": 0
}

balance should not equal unconfirmedBalance, this is very confusing, I was expecting something like this:

{
  "balance": 891945724,
  "txCount": 196,
  "unconfirmedBalance": 19300529,
  "unconfirmedTxCount": 0
}

I'm looking for an API to give me the same data the Vertcoin wallet does

gertjaap commented 6 years ago

I think the indexer doesn't yet support immature balance (mining outputs). Will have to look into that.