Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: The Madhatter on December 13, 2010, 02:54:41 PM



Title: 0.3.18 Bug Report on "getreceivedbyaccount" display
Post by: The Madhatter on December 13, 2010, 02:54:41 PM
Hey,

Looks like the "getreceivedbyaccount" rpc display is broken on 0.3.18.

Quote
# ~/bin/bitcoind getnewaddress
1Fs5rqB2sXZ3kax1r3HfuYpK2ksSxLYJT8

* Does a 0.01 BTC spend from another computer to 1Fs5rqB2sXZ3kax1r3HfuYpK2ksSxLYJT8 *

(BBE: http://blockexplorer.com/a/7BMcTdZkY3 (http://blockexplorer.com/a/7BMcTdZkY3))

Quote
# ~/bin/bitcoind getreceivedbyaccount 1Fs5rqB2sXZ3kax1r3HfuYpK2ksSxLYJT8 0
0.00000000

* Trying some PHP code to talk to the JSON-RPC directly *

Quote
# cat test.php
<?
  require "config.inc.php";
  require "functions.inc.php";

  $bitcoin=bitcoin_api_call("getamountreceived",array("1Fs5rqB2sXZ3kax1r3HfuYpK2ksSxLYJT8",0)); //0 confirmations. I've also tried 1+
  print_r($bitcoin);
?>
# php test.php
stdClass Object
(
    [result] => 0.01
    [error] =>
    [id] => 1
)

So I see the 0.01 BTC on my php client, but not on the command line. Yes, "getinfo" and other commands work. Yes, I have proper "allowrpc" command line options. Yes, I've tried waiting for confirmations. I get the exact same result.

Seems to be a problem with the display when you use the bitcoind as a client?? Can anyone confirm that they have the same problem?

OS: FreeBSD 7.2-RELEASE-p8/amd64

Thanks.


Title: Re: 0.3.18 Bug Report on "getreceivedbyaccount" display
Post by: theymos on December 13, 2010, 04:41:26 PM
You should be using getreceivedbyaddress rather than getreceivedbyaccount. You didn't assign that address to any account.


Title: Re: 0.3.18 Bug Report on "getreceivedbyaccount" display
Post by: Gavin Andresen on December 13, 2010, 05:10:06 PM
You should be using getreceivedbyaddress rather than getreceivedbyaccount. You didn't assign that address to any account.

What theymos said.  You're asking for the balance of the account named '1Fs5rqB2sXZ3kax1r3HfuYpK2ksSxLYJT8', and there is no such account.

Whether bitcoin should return an error (instead of 0) if you ask for the balance of a non-existant account is debatable...


Title: Re: 0.3.18 Bug Report on "getreceivedbyaccount" display
Post by: davout on December 13, 2010, 08:26:59 PM
Whether bitcoin should return an error (instead of 0) if you ask for the balance of a non-existant account is debatable...

I vote for "it should", 0 should be the answer for when an account balance is actually zero


Title: Re: 0.3.18 Bug Report on "getreceivedbyaccount" display
Post by: The Madhatter on December 14, 2010, 12:06:05 AM
You should be using getreceivedbyaddress rather than getreceivedbyaccount. You didn't assign that address to any account.

What is the difference between an address and an account? Are they not the same thing? In version 0.3.13 they seem to perform the same function.


Title: Re: 0.3.18 Bug Report on "getreceivedbyaccount" display
Post by: theymos on December 14, 2010, 12:44:19 AM
What is the difference between an address and an account? Are they not the same thing? In version 0.3.13 they seem to perform the same function.

"Label" was renamed to "account" recently. Addresses are grouped into accounts.

Lots of people have been confusing "address" and "account". The name should be changed to something more clear.


Title: Re: 0.3.18 Bug Report on "getreceivedbyaccount" display
Post by: The Madhatter on December 14, 2010, 12:49:15 AM
Ahh, ok. Thanks for clearing that up. :)