deso-protocol / backend

HTTP API for a DeSo node
https://docs.deso.org
MIT License
134 stars 86 forks source link

Bug in /api/v1/balance #507

Closed ropolexi closed 10 months ago

ropolexi commented 1 year ago

running this command curl --header "Content-Type: application/json" --request POST --data '{ "PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":8 }' https://node.deso.org/api/v1/balance

Here is the result, {"Error":"","ConfirmedBalanceNanos":70282964,"UnconfirmedBalanceNanos":70282964,"UTXOs":null}

UnconfirmedBalanceNanos is always equal to ConfirmedBalanceNanos. It should go to zero after confirmation as I think @lazynina

ropolexi commented 1 year ago

Here is another results, which does not makes any sense, the balance increases for no reason curl --header "Content-Type: application/json" --request POST --data '{ "PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":8 }' https://diamondapp.com/api/v1/balance

{"Error":"","ConfirmedBalanceNanos":3739425289,"UnconfirmedBalanceNanos":0,"UTXOs":[{"TransactionIDBase58Check":"3JuETCupZXBDijpdjHk68hYCxYLixum5bfAczwKWFVsnkqA1qWUP4D","Index":2,"AmountNanos":376201250,"PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":35227,"UtxoType":"UtxoTypeUnknown","BlockHeight":226777},{"TransactionIDBase58Check":"3JuETKp5B3nkCbBc1b7BdTC6NrotChYDmsPD3vfWynR6EsPQmFXhfQ","Index":1,"AmountNanos":2534969821,"PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":35538,"UtxoType":"UtxoTypeOutput","BlockHeight":226466},{"TransactionIDBase58Check":"3JuETTRCzkrg7KgYgYv2BMcfAYUyKMsrnfU5PouPnJ5o7EyZxva48f","Index":0,"AmountNanos":50000,"PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":35200,"UtxoType":"UtxoTypeOutput","BlockHeight":226804},{"TransactionIDBase58Check":"3JuEU3ADfGWvw5vyzDDPpSriX8TAJSi74Mb9zQ6iBqnRX5PZgNo6Gq","Index":1,"AmountNanos":100000000,"PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":35403,"UtxoType":"UtxoTypeUnknown","BlockHeight":226601},{"TransactionIDBase58Check":"3JuEULB7qbaLyt16f6WKgyN5kmBnyuwzzJDciHs4CzVk9vGBRa72a1","Index":1,"AmountNanos":50000,"PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":35217,"UtxoType":"UtxoTypeOutput","BlockHeight":226787},{"TransactionIDBase58Check":"3JuESq1mxPv6mejWEFWh2doBP3jKe4UMDvRwLtqv6n4ymfw2hm9MKw","Index":1,"AmountNanos":747900,"PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":35220,"UtxoType":"UtxoTypeOutput","BlockHeight":226784},{"TransactionIDBase58Check":"3JuESyDfmmexaycxmb47GDsSsQfqSNDVPrti6wGo8h2wEJyd3LYzsv","Index":0,"AmountNanos":727406318,"PublicKeyBase58Check":"BC1YLhBH8oPqRRAejbUu9BbFquhLFz6GQ8ZbKk6SAWtFsbdcthVTEw8","Confirmations":35436,"UtxoType":"UtxoTypeOutput","BlockHeight":226568}]}

ropolexi commented 1 year ago

The balance increase only happens on diamond app.com, ConfirmedBalanceNanos =3739425289 on other nodes ConfirmedBalanceNanos=70282964 Actual value should be 70282964 I wish I had that large amount, apparently its a bug, how to fix /api/v1/balance? @lazynina @kanshi

lazynina commented 1 year ago

@ropolexi - looking at the results from node.deso.org and they appear to be correct. The confirmedBalance is the total balance a public key has in committed blocks where as unconfirmedBalance is the confirmedBalance plus (or minus) any balance changes in the mempool.

Regarding diamond's API, I'll check in with the developer there. Please let me know if you have any further questions.

lazynina commented 10 months ago

diamond updated it's api and it's now returning the same results. This issue is resolved. Please re-open if you experience any further issues.