Bitcoin Forum
December 19, 2018, 08:52:40 AM *
News: Latest Bitcoin Core release: 0.17.0 [Torrent].
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: `getbalance accountname` returning incorrect amount?  (Read 2137 times)
tgerring
Full Member
***
Offline Offline

Activity: 142
Merit: 100


Hive/Ethereum


View Profile WWW
August 29, 2013, 05:03:56 AM
 #1

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

Hive, a beautiful wallet for Mac OS X, now available for testing. Follow the story here.
BitcoinKit.framework and Tor.framework, now available to iOS and Mac OS X developers
Tweeting at @hivewallet. Donations appreciated at 142m1MpXHhymF4aASiWwYohe1Y55v5BQwc
1545209560
Hero Member
*
Offline Offline

Posts: 1545209560

View Profile Personal Message (Offline)

Ignore
1545209560
Reply with quote  #2

1545209560
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1545209560
Hero Member
*
Offline Offline

Posts: 1545209560

View Profile Personal Message (Offline)

Ignore
1545209560
Reply with quote  #2

1545209560
Report to moderator
1545209560
Hero Member
*
Offline Offline

Posts: 1545209560

View Profile Personal Message (Offline)

Ignore
1545209560
Reply with quote  #2

1545209560
Report to moderator
1545209560
Hero Member
*
Offline Offline

Posts: 1545209560

View Profile Personal Message (Offline)

Ignore
1545209560
Reply with quote  #2

1545209560
Report to moderator
tgerring
Full Member
***
Offline Offline

Activity: 142
Merit: 100


Hive/Ethereum


View Profile WWW
August 29, 2013, 02:08:00 PM
 #2

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

Hive, a beautiful wallet for Mac OS X, now available for testing. Follow the story here.
BitcoinKit.framework and Tor.framework, now available to iOS and Mac OS X developers
Tweeting at @hivewallet. Donations appreciated at 142m1MpXHhymF4aASiWwYohe1Y55v5BQwc
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1001



View Profile
August 29, 2013, 07:16:13 PM
 #3

Accounts can be negative.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
tgerring
Full Member
***
Offline Offline

Activity: 142
Merit: 100


Hive/Ethereum


View Profile WWW
August 29, 2013, 08:06:20 PM
 #4

Accounts can be negative.

Perhaps I'm misunderstanding the use of accounts.

Could you expand on that? Or happy to read any reference documentation.

Hive, a beautiful wallet for Mac OS X, now available for testing. Follow the story here.
BitcoinKit.framework and Tor.framework, now available to iOS and Mac OS X developers
Tweeting at @hivewallet. Donations appreciated at 142m1MpXHhymF4aASiWwYohe1Y55v5BQwc
grue
Legendary
*
Offline Offline

Activity: 2058
Merit: 1140



View Profile
August 29, 2013, 08:56:18 PM
 #5

https://en.bitcoin.it/wiki/Accounts_explained

It is pitch black. You are likely to be eaten by a grue.

Adblock for annoying signature ads | Enhanced Merit UI
tgerring
Full Member
***
Offline Offline

Activity: 142
Merit: 100


Hive/Ethereum


View Profile WWW
August 30, 2013, 03:23:58 AM
 #6

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?

Hive, a beautiful wallet for Mac OS X, now available for testing. Follow the story here.
BitcoinKit.framework and Tor.framework, now available to iOS and Mac OS X developers
Tweeting at @hivewallet. Donations appreciated at 142m1MpXHhymF4aASiWwYohe1Y55v5BQwc
theymos
Administrator
Legendary
*
expert
Offline Offline

Activity: 3234
Merit: 4105


View Profile
August 30, 2013, 03:31:33 AM
 #7

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

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
tgerring
Full Member
***
Offline Offline

Activity: 142
Merit: 100


Hive/Ethereum


View Profile WWW
September 05, 2013, 03:49:13 PM
 #8

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

Hive, a beautiful wallet for Mac OS X, now available for testing. Follow the story here.
BitcoinKit.framework and Tor.framework, now available to iOS and Mac OS X developers
Tweeting at @hivewallet. Donations appreciated at 142m1MpXHhymF4aASiWwYohe1Y55v5BQwc
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1001



View Profile
September 05, 2013, 05:07:36 PM
 #9

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.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
tgerring
Full Member
***
Offline Offline

Activity: 142
Merit: 100


Hive/Ethereum


View Profile WWW
September 05, 2013, 05:35:20 PM
 #10

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.

Hive, a beautiful wallet for Mac OS X, now available for testing. Follow the story here.
BitcoinKit.framework and Tor.framework, now available to iOS and Mac OS X developers
Tweeting at @hivewallet. Donations appreciated at 142m1MpXHhymF4aASiWwYohe1Y55v5BQwc
nagagaga
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
June 10, 2018, 12:16:13 PM
 #11

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?
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!