Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: subcoin on July 19, 2013, 01:06:47 AM



Title: Need help with bitcoind and jsonRPCClient
Post by: subcoin on July 19, 2013, 01:06:47 AM
Hi,
I wonder, if somebody could help with with PHP jsonRPCClient.

I am trying to pull 10 last transactions for ALL accounts from bitcoind using jsonRPCClient.

I do something like this:
$account = '';
$count_trns = 10;
$start_from = 0;
$trn_array = $bitcoin->listtransactions($account, $count_trns, $start_from);

This gives me ONLY the transactions for the main account (where account name is empty).
The listtransactions says: "If [account] not provided will return recent transaction from all accounts."
But when I do:
$trn_array = $bitcoin->listtransactions($count_trns, $start_from);

It doesn't work (PHP Warning:  fopen(http://...@xx.xx.xx.xx:8332/): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
 in /../jsonRPCClient.php on line 132)

I've temporary resolved it by calling listtransactions(); - without any parameters
But as the list of transactions grows I would like to call it with limit.

So, the question is how can I pull 10 last transactions for ALL accounts?





Title: Re: Need help with bitcoind and jsonRPCClient
Post by: subcoin on July 19, 2013, 01:10:42 AM
sorry, for posting, I've searched and found my answer...

need to call the account = '*'

Thanks! :)


Title: Re: Need help with bitcoind and jsonRPCClient
Post by: kjj on July 19, 2013, 01:53:24 PM
Yes, the root problem that you can't omit a leading argument.  All three of the parameters are optional, but if present, they will be interpreted in the order listed.  This may not be obvious to people that don't program much, so I'm pointing it out to future searchers.

The default account is named by an empty string.  If you look at the bitcoind source code, you'll see that the account name defaults to '*', and is overwritten with the first argument.