Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getbalance and listaccounts returning incorrect balance (testnet) #6042

Closed
bitcartel opened this issue Apr 21, 2015 · 5 comments
Closed

getbalance and listaccounts returning incorrect balance (testnet) #6042

bitcartel opened this issue Apr 21, 2015 · 5 comments

Comments

@bitcartel
Copy link

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.

@bitcartel bitcartel changed the title getbalance and listaccounts returning incorrect balance getbalance and listaccounts returning incorrect balance (testnet) Apr 21, 2015
@luke-jr
Copy link
Member

luke-jr commented Apr 22, 2015

If there is a bug here, it's listunspent suggesting that UTXOs are associated with addresses or accounts: They are not.

@sipa
Copy link
Member

sipa commented Apr 22, 2015

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.

@bitcartel
Copy link
Author

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?

@laanwj
Copy link
Member

laanwj commented May 18, 2015

@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).

@hamnaz
Copy link

hamnaz commented Oct 9, 2018

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
}
]

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants