Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: chiefpriest on March 19, 2023, 12:42:01 AM



Title: Difference in getbalance and total sum of listunspent
Post by: chiefpriest on March 19, 2023, 12:42:01 AM

Bitcoin Core Version: bitcoin-core-24.-
Wallet version : 169900
Operating System: Ubuntu 22.04 64-bit
System Hardware Specs: N/A
Description of Problem: is there a reason why the total sum of listunspent and getbalances are not the same
Any Related Addresses: N/A
Any Related Transaction IDs: N/A
Screenshot of the problem: N/A
Log Files from the Bitcoin Client: N/A




bitcoin-cli listunspent | grep amount
    "amount": 0.00002129,
    "amount": 0.00002129,
    "amount": 0.00004280,
    "amount": 0.00002756,
    "amount": 0.00004278,
    "amount": 0.00004263,
    "amount": 0.00004263,


bitcoin-cli getbalances
{
  "mine": {
    "trusted": 0.00002756,
    "untrusted_pending": 0.00000000,
    "immature": 0.00000000,
    "used": 0.00021342
  }
}


Title: Re: Difference in getbalance and total sum of listunspent
Post by: achow101 on March 19, 2023, 12:58:41 AM
I don't see where they are not the same. All of the amounts sum to the same value. Your wallet appears to have enabled the avoid_reuse flag, so the values in UTXOs for scripts that have already been used before will be counted in the "used" balance separately from "trusted".


Title: Re: Difference in getbalance and total sum of listunspent
Post by: nc50lc on March 19, 2023, 07:22:38 AM
-snip-    "used": 0.00021342
"used" doesn't mean that those are spent, it only means (in layman terms) that you've received bitcoins through an addresses, spent it and then received coins through that address again.
In case you unintentionally enabled the flag, you can disable it with:
Code:
bitcoin-cli setwalletflag "avoid_reuse" false


On a side note, accumulating more UTXOs with small amounts like those could end up causing you to pay high txn fee if you need to spend hundreds of them in one transaction.
If those are mining pool payments, I'd consider setting a higher minimum payment amount.


Title: Re: Difference in getbalance and total sum of listunspent
Post by: chiefpriest on March 19, 2023, 07:55:15 AM
I don't see where they are not the same. All of the amounts sum to the same value. Your wallet appears to have enabled the avoid_reuse flag, so the values in UTXOs for scripts that have already been used before will be counted in the "used" balance separately from "trusted".


Is there any real potential benefits for settings avoid_reuse as False. And thanks for the explanation. I did some calculations and yeah, it matches.