I have a tiny question regarding the Bitcoin JSON-RPC API. I have a transaction on Testnet which sends one coin to an other address owned by me (on an other account than the sender). The sending address, mtGaEd9zZU8B7aYSuQiDFZTo2wiS8dWb3c
, is listed under the default account, running getaccount mtGaEd9zZU8B7aYSuQiDFZTo2wiS8dWb3c
outputs indeed an empty string. The receiving address, mzcj8xYome3gmAWZG57yutv14sctPxbPV6
, is listed under an account named test
, as expected running getaccount mzcj8xYome3gmAWZG57yutv14sctPxbPV6
returns test
. Both addresses also show up when I use getaddressesbyaccount
, but the change that went to address mnUJRd9CL3GV1QbWFxJxLj2DgE1ADSB8oR
, which also returns an emtpy string when using it as argument to getaccount
, doesn't show up in the getaddressesbyaccount
call output. Why is that? I can't sum the balances of each addresses now for a reliable account balance, only getbalance
return the right answer.
2 Answers
Call listreceivedbyaddress(0, true) to get all of your addresses (even the empty ones or those who have a zero-confirmations balance).
By default (parameterless) it will only list the addresses that contain some confirmed balance and those who have at least one confirmation for their unconfirmed balance.
-
1I believe I was talking about
getaddressesbyaccount
notlistreceivedbyaddress
. Don't get me wrong, I'm not asking a solution (getbalance
works just fine), I'm trying to understand whygetaddressesbyaccount
does not work.– JoriCommented Mar 1, 2014 at 22:38 -
And why would
mnUJRd9CL3GV1QbWFxJxLj2DgE1ADSB8oR
have zero confirmations? It is in the same transaction asmzcj8xYome3gmAWZG57yutv14sctPxbPV6
.– JoriCommented Mar 1, 2014 at 22:41
It doesn't show up in the results from getaddressesbyaccount() because addresses are only associated with accounts by use of getnewaddress() or setaccount().
-
Why did they use this approach? It doesn't make sense to me. Also is there any other way to show all Bitcoin addresses?– JoriCommented Nov 29, 2013 at 19:16