getbalance and listaccounts returning incorrect balance (testnet) #6042

issue bitcartel opened 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.

    bitcoin-cli -testnet getinfo
    {
        "version" : 100000,
        "protocolversion" : 70002,
        "walletversion" : 60000,
        "balance" : 2.66964380,
        "blocks" : 350108,
        "timeoffset" : 0,
        "connections" : 0,
        "proxy" : "",
        "difficulty" : 1.00000000,
        "testnet" : true,
        "keypoololdest" : 1426225664,
        "keypoolsize" : 101,
        "paytxfee" : 0.00000000,
        "relayfee" : 0.00001000,
        "errors" : ""
    }
    
    bitcoin-cli -testnet listaccounts
    {
        "" : 1.64964380,
        "elmo" : 1.02000000,
    }
    
    bitcoin-cli -testnet getbalance elmo
    1.02000000
    
    bitcoin-cli -testnet listreceivedbyaccount 1 true       
    [
        {
            "account" : "",
            "amount" : 2.06080000,
            "confirmations" : 1040
        },
        {
            "account" : "elmo",
            "amount" : 1.02000000,
            "confirmations" : 22149
        },
    

    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.

    {
            "txid" : "42e2579dd090415713510c5cc58aa13afd14cfc2a1fb6ebee873afc169927e8b",
            "vout" : 0,
            "address" : "myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi",
            "account" : "elmo",
            "scriptPubKey" : "76a914c5d6d3854e653be3c31e66d322cb0a05cb0a17c888ac",
            "amount" : 0.01000000,
            "confirmations" : 22149,
            "spendable" : true
    }
    

    Here are the two addresses associated with account "elmo"

    bitcoin-cli -testnet getaddressesbyaccount elmo
    [
        "mkwLg4ARNWimVW1Bh9uxv9SKdfNnPHRHWr",
        "myZ2mEYZt1CyRPgdE6oXRbAJWbaaTtTwRi"
    ]
    

    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: 2026-04-13 15:15 UTC

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