Author

Topic: bitcoind listunspent for account (Read 1795 times)

legendary
Activity: 971
Merit: 1000
April 01, 2013, 01:19:15 PM
#3
Well either I'm doing something wrong or there's something wrong with my bitcoind.
Code:
$ bitcoind getaddressesbyaccount bitcoiner
[
    "17A1QM8Tjjd8cyHPYmzC3M4ou9Q8RXWjKv",
    "14iRpAsjszmbUY1HrU9yarPJm1sbtKM6Ew",
    "19ZZ8DZsb5qgchuKPZWET7Uj8rDoj4KgmB"
]
$ bitcoind listaddressgroupings | grep 17A1QM8Tjjd8cyHPYmzC3M4ou9Q8RXWjKv
(nothing here...)
$ bitcoind listaddressgroupings | grep 14iRpAsjszmbUY1HrU9yarPJm1sbtKM6Ew  #just to check...
            "14iRpAsjszmbUY1HrU9yarPJm1sbtKM6Ew",
So the first thing is that listaddressgroupings doesn't list all addresses in the wallet.
The second thing is that for every address returned by listaddressgroupings (except for these returned by getaddressesbyaccount) getaccount gives nothing. Here's an output of a little script implementing Stephen's idea (checking for bitcoiner account):
Code:
$ php test.php
array(2) {
  [0]=>
  string(34) "14iRpAsjszmbUY1HrU9yarPJm1sbtKM6Ew"
  [1]=>
  string(34) "19ZZ8DZsb5qgchuKPZWET7Uj8rDoj4KgmB"
}
Code:
Code fragment using jsonRPCClient.php:
$addresses = $this->conn->listaddressgroupings();
$addresses = $addresses[0];
$ret = array();
foreach($addresses as $address) {
    if($this->conn->getaccount($address[0]) == $account)
        $ret[] = $address[0];
}
var_dump($ret);
legendary
Activity: 2506
Merit: 1010
March 31, 2013, 04:36:05 PM
#2
Is there a way to get all addresses associated with an account?

You can use
 listaddressgroupings
to get all the addresses in the wallet and then getaccount to determine which account each address is in.
You could filter that with the ones you already know from getaddressesbyaccount and that would leave a smaller list (just of change addresses that exist for all accounts).
legendary
Activity: 971
Merit: 1000
March 31, 2013, 11:29:30 AM
#1
Is it possible to list unspent transaction outputs only for one account using bitcoind RPC API?
I have:
Code:
bitcoind listaccounts
{
    "" : 0.00285696,
    "account1" : 0.11652234,
    "account2" : 0.00000000
}
and I would like to get unspent transaction outputs only for "account1", not all accounts. I've tried using getaddressesbyaccount and then feeding listunspent with it, but I think it doesn't include these auto-generated addresses used for a change (and I need these too). Is there a way to get all addresses associated with an account?
Jump to: