getbalance and listaccounts returning incorrect balance (testnet) #6042

issue bitcartel openend this issue on April 21, 2015
  1. bitcartel commented at 9:31 pm on April 21, 2015: none

    Problem: Testnet wallet account “elmo” is showing a balance of 1.02 but should instead show 0.01.

     0bitcoin-cli -testnet getinfo
     1{
     2    "version" : 100000,
     3    "protocolversion" : 70002,
     4    "walletversion" : 60000,
     5    "balance" : 2.66964380,
     6    "blocks" : 350108,
     7    "timeoffset" : 0,
     8    "connections" : 0,
     9    "proxy" : "",
    10    "difficulty" : 1.00000000,
    11    "testnet" : true,
    12    "keypoololdest" : 1426225664,
    13    "keypoolsize" : 101,
    14    "paytxfee" : 0.00000000,
    15    "relayfee" : 0.00001000,
    16    "errors" : ""
    17}
    18
    19bitcoin-cli -testnet listaccounts
    20{
    21    "" : 1.64964380,
    22    "elmo" : 1.02000000,
    23}
    24
    25bitcoin-cli -testnet getbalance elmo
    261.02000000
    27
    28bitcoin-cli -testnet listreceivedbyaccount 1 true       
    29[
    30    {
    31        "account" : "",
    32        "amount" : 2.06080000,
    33        "confirmations" : 1040
    34    },
    35    {
    36        "account" : "elmo",
    37        "amount" : 1.02000000,
    38        "confirmations" : 22149
    39    },
    

    However when using listunspent to examine the UTXO in the wallet, there is only one UTXO assigned to the account “elmo” and this UTXO shows a balance of 0.01.

    0{
    1        "txid" : "42e2579dd090415713510c5cc58aa13afd14cfc2a1fb6ebee873afc169927e8b",
    2        "vout" : 0,
    3        "address" : "myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi",
    4        "account" : "elmo",
    5        "scriptPubKey" : "76a914c5d6d3854e653be3c31e66d322cb0a05cb0a17c888ac",
    6        "amount" : 0.01000000,
    7        "confirmations" : 22149,
    8        "spendable" : true
    9}
    

    Here are the two addresses associated with account “elmo”

    0bitcoin-cli -testnet getaddressesbyaccount elmo
    1[
    2    "mkwLg4ARNWimVW1Bh9uxv9SKdfNnPHRHWr",
    3    "myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi"
    4]
    

    Two separate block explorers report the balance of each address as:

    http://tbtc.blockr.io/address/info/myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi https://www.blocktrail.com/tBTC/address/myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi 0.01

    http://tbtc.blockr.io/address/info/mkwLg4ARNWimVW1Bh9uxv9SKdfNnPHRHWr https://www.blocktrail.com/tBTC/address/mkwLg4ARNWimVW1Bh9uxv9SKdfNnPHRHWr 0

    So it appears that bitcoind is returning an incorrect balance of 1.02 instead of 0.01.

  2. bitcartel renamed this:
    getbalance and listaccounts returning incorrect balance
    getbalance and listaccounts returning incorrect balance (testnet)
    on Apr 21, 2015
  3. luke-jr commented at 1:19 am on April 22, 2015: member
    If there is a bug here, it’s listunspent suggesting that UTXOs are associated with addresses or accounts: They are not.
  4. sipa commented at 5:33 am on April 22, 2015: member

    I think the bug here is reporting an account name for the listunspent output. UTXOs are not associated with accounts; they are shared with the whole wallet, always.

    Accounts are just bean counters. Their value is increased when a transaction is received with an address associated with the account. Their value is decreased when a sendfrom RPC is issued or using the move RPC. Using normal sendtoaddress or sendmany will always debit the "" account. This is a frequent source of confusion, and the account system is being deprecated for this and other reasons.

  5. bitcartel commented at 6:35 am on April 22, 2015: none

    Thanks, I agree.

    So it’s confirmed that the account system will be deprecated for 0.11 as discussed in #3816 ? Will JSON-RPC responses such as listunspent continue to return an account field during the deprecation phase or will they be removed immediately?

  6. laanwj commented at 8:02 am on May 18, 2015: member
    @bitcartel Accounts will be replaced by labels, which are just a handle for an output script/address. At most the return field will be renamed at some point (not for 0.11 though).
  7. laanwj closed this on May 18, 2015

  8. hamnaz commented at 12:54 pm on October 9, 2018: none

    any suggestion for me, what balance i have ?

    ~/bitcoin-0.16.3/bin$ ./bitcoin-cli getwalletinfo { “walletname”: “wallet.dat”, “walletversion”: 159900, “balance”: 19.86576864, “unconfirmed_balance”: 0.00000000, “immature_balance”: 0.00000000, “txcount”: 5666, “keypoololdest”: 1538466741, “keypoolsize”: 1000, “keypoolsize_hd_internal”: 1000, “paytxfee”: 0.00000000,

    ~/bitcoin-0.16.3/bin$ ./bitcoin-cli getbalance 19.86576864

    ~/bitcoin-0.16.3/bin$ ./bitcoin-cli getreceivedbyaccount "" 253.57105799

    ~/bitcoin-0.16.3/bin$ ./bitcoin-cli listreceivedbyaccount [ { “account”: “”, “amount”: 253.55285799, “confirmations”: 12947 } ]


    ~/bitcoin-0.16.3/bin$ ./bitcoin-cli listaccounts { “”: 0.00020000, “wallet.dat”: 0.00000000 }


    ~/bitcoin-0.16.3/bin$ ./bitcoin-cli listunspent [ { “txid”: “15e9ee719ddf0e1f68586b856c5d8e58c7bcb37c955f03a91ed6d9531d68431b”, “vout”: 3, “address”: “1HyAcHNbUaW8pSWYQWvsobpQFd44BK4xgc”, “account”: “”, “scriptPubKey”: “76a914ba2153b777d3aa93e3ad6fe549636be5204075b788ac”, “amount”: 0.00020000, “confirmations”: 208324, “spendable”: true, “solvable”: true, “safe”: true }, { “txid”: “94e247464e6d5f323b0c781ffe0c42562afeafd01430fb7f55ad58b3cf5eb928”, “vout”: 0, “address”: “17zHADrQXRtTycekZzm5NcxkmxduFTwi7v”, “account”: “”, “scriptPubKey”: “76a9144ca5f410395ed81039a8230fb4a825f96e0080c288ac”, “amount”: 0.00020000, “confirmations”: 119800, “spendable”: true, “solvable”: true, “safe”: true } ]

  9. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 03:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me