Author

Topic: `getbalance accountname` returning incorrect amount? (Read 2249 times)

newbie
Activity: 13
Merit: 0
I've been swapping wallet.dat back and forth all night to simulate transactions between wallets and I'm receiving what appears to be incorrect information from `getbalance accountname` (which lists more than the wallet contains). Any idea what's going on or how to correct it? Cycling bitcoin-qt (with server=1) doesn't help. This is on testnet

Code:
$ bitcoind getbalance
1.00060000

$ bitcoind getbalance THISISTHEACCOUNTNAME
2.43000000

$ bitcoind getinfo && bitcoind listunspent{
    "version" : 80300,
    "protocolversion" : 70001,
    "walletversion" : 60000,
    "balance" : 1.00060000,
    "blocks" : 103288,
    "timeoffset" : 0,
    "connections" : 2,
    "proxy" : "",
    "difficulty" : 1.00000000,
    "testnet" : true,
    "keypoololdest" : 1377735562,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "unlocked_until" : 0,
    "errors" : ""
}
[
    {
        "txid" : "9547db820d37c81603d1f7bee78c4b007d3a8ba39c4f8b9b98f250562ffbefca",
        "vout" : 1,
        "address" : "mr2udJKNUS9UrzxngqFuF6xvVJSskuGAwo",
        "scriptPubKey" : "76a914735b82684e35a836223a19ceea94091fb32dd9c688ac",
        "amount" : 0.00060000,
        "confirmations" : 11
    },
    {
        "txid" : "b2c77af6708d0247912a1b934b713a03d459d9a04fc86d6b5035fc5244cc448a",
        "vout" : 1,
        "address" : "mzKWkrjFy8CYCMg6Qjwm5DakdwhWWrmFbR",
        "account" : "THISISTHEACCOUNTNAME",
        "scriptPubKey" : "76a914ce407f12d457a6a743f6c210606ff55a207c735688ac",
        "amount" : 0.40000000,
        "confirmations" : 1
    },
    {
        "txid" : "b37b9cc5a3e86526697a171b31b59e91a05081e641f8e1ec319fefb7625c925c",
        "vout" : 0,
        "address" : "mzKWkrjFy8CYCMg6Qjwm5DakdwhWWrmFbR",
        "account" : "THISISTHEACCOUNTNAME",
        "scriptPubKey" : "76a914ce407f12d457a6a743f6c210606ff55a207c735688ac",
        "amount" : 0.60000000,
        "confirmations" : 2
    }
]

$ bitcoind getaddressesbyaccount THISISTHEACCOUNTNAME
[
    "mzKWkrjFy8CYCMg6Qjwm5DakdwhWWrmFbR"
]



Hey Im getting this error too! Do you have any idea how to solve this issue?
full member
Activity: 142
Merit: 100
Hive/Ethereum
They are not intended for the use you are attempting.

Someone's got to do something at some point since this appears to be a problem not willing to go away. The code I posted was a drop-in replacement for how I expected `getbalance` to work in conjunction with `sendfrom`. Hopefully it helps someone else too.
kjj
legendary
Activity: 1302
Merit: 1025
I'm still not sure what's going on, since I never used the `move` command, but it's apparent that the account balance is not working as expected.

This is a frequent complaint.  Search the boards for many more examples of threads substantially identical to yours.

Accounts do not work the way you think they do.  They are not intended for the use you are attempting.
full member
Activity: 142
Merit: 100
Hive/Ethereum
I'm still not sure what's going on, since I never used the `move` command, but it's apparent that the account balance is not working as expected. Since I'm mapping a single account to a single address, my workaround is to rely on `listunspent` and build a dictionary of balances. Python example:

Code:
def getaccountbalances():
    totals = {}

    unspentinputs = self.access.listunspent()
    for tx in unspentinputs:
        if 'account' in tx and tx['amount'] > 0:
            if not tx['account'] in totals:
                totals[tx['account']] = 0
            totals[tx['account']] += round(tx['amount'], 8)

    return totals
administrator
Activity: 5222
Merit: 13032
The wiki mentions "debits", so I understand the possibility for an account to go negative. But if new transactions to an address associated with an account act as the only credit mechanism, under what circumstances would an account show a balance more than the wallet total?

Code:
getbalance
   20
getbalance ac
   20
move '' ac 20000
getbalance ac
   20020
getbalance
   20
sendtoaddress 1A... 20
getbalance
   0
getbalance ac
   20020
full member
Activity: 142
Merit: 100
Hive/Ethereum
Quote
The sendfrom method sends coins and debits the specified account.

The wiki mentions "debits", so I understand the possibility for an account to go negative. But if new transactions to an address associated with an account act as the only credit mechanism, under what circumstances would an account show a balance more than the wallet total?
full member
Activity: 142
Merit: 100
Hive/Ethereum
Accounts can be negative.

Perhaps I'm misunderstanding the use of accounts.

Could you expand on that? Or happy to read any reference documentation.
kjj
legendary
Activity: 1302
Merit: 1025
Accounts can be negative.
full member
Activity: 142
Merit: 100
Hive/Ethereum
Shutting down bitcoin-qt overnight and letting it catch up in the morning didn't seem to have any effect. Still not sure what to do
full member
Activity: 142
Merit: 100
Hive/Ethereum
I've been swapping wallet.dat back and forth all night to simulate transactions between wallets and I'm receiving what appears to be incorrect information from `getbalance accountname` (which lists more than the wallet contains). Any idea what's going on or how to correct it? Cycling bitcoin-qt (with server=1) doesn't help. This is on testnet

Code:
$ bitcoind getbalance
1.00060000

$ bitcoind getbalance THISISTHEACCOUNTNAME
2.43000000

$ bitcoind getinfo && bitcoind listunspent{
    "version" : 80300,
    "protocolversion" : 70001,
    "walletversion" : 60000,
    "balance" : 1.00060000,
    "blocks" : 103288,
    "timeoffset" : 0,
    "connections" : 2,
    "proxy" : "",
    "difficulty" : 1.00000000,
    "testnet" : true,
    "keypoololdest" : 1377735562,
    "keypoolsize" : 101,
    "paytxfee" : 0.00000000,
    "unlocked_until" : 0,
    "errors" : ""
}
[
    {
        "txid" : "9547db820d37c81603d1f7bee78c4b007d3a8ba39c4f8b9b98f250562ffbefca",
        "vout" : 1,
        "address" : "mr2udJKNUS9UrzxngqFuF6xvVJSskuGAwo",
        "scriptPubKey" : "76a914735b82684e35a836223a19ceea94091fb32dd9c688ac",
        "amount" : 0.00060000,
        "confirmations" : 11
    },
    {
        "txid" : "b2c77af6708d0247912a1b934b713a03d459d9a04fc86d6b5035fc5244cc448a",
        "vout" : 1,
        "address" : "mzKWkrjFy8CYCMg6Qjwm5DakdwhWWrmFbR",
        "account" : "THISISTHEACCOUNTNAME",
        "scriptPubKey" : "76a914ce407f12d457a6a743f6c210606ff55a207c735688ac",
        "amount" : 0.40000000,
        "confirmations" : 1
    },
    {
        "txid" : "b37b9cc5a3e86526697a171b31b59e91a05081e641f8e1ec319fefb7625c925c",
        "vout" : 0,
        "address" : "mzKWkrjFy8CYCMg6Qjwm5DakdwhWWrmFbR",
        "account" : "THISISTHEACCOUNTNAME",
        "scriptPubKey" : "76a914ce407f12d457a6a743f6c210606ff55a207c735688ac",
        "amount" : 0.60000000,
        "confirmations" : 2
    }
]

$ bitcoind getaddressesbyaccount THISISTHEACCOUNTNAME
[
    "mzKWkrjFy8CYCMg6Qjwm5DakdwhWWrmFbR"
]
Jump to: