Unexpected result after calling RPC 'listaccounts', 'getaccountaddress', 'getreceivedbyaddress' sequentially

0

bitcoin > bitcoin-cli listaccounts
{
  "": 5648.99996160
}

bitcoin > bitcoin-cli getaccountaddress ""
mui4xgNgZBr3XhdL4dDDHkRFEvSXZmSi7t

bitcoin > bitcoin-cli getreceivedbyaddress mui4xgNgZBr3XhdL4dDDHkRFEvSXZmSi7t
0.00000000

I expect it will return 5648.99996160 after calling 'getreceivedbyaddress'.

Anderson

Posted 2017-11-22T08:31:48.030

Reputation: 115

Answers

1

An account can have multiple associated addresses. Presumably you had another address associated with "" beforehand, and received money using that address.

The getaccountaddress RPC call gives a fresh address. If money had been received already on the previous account address, a new one is created and associated with the account.

Pieter Wuille

Posted 2017-11-22T08:31:48.030

Reputation: 54 032

Thank you! However I still get problem. I call RPC getaddressesbyaccount and get 3 addresses. Then I call RPC getreceivedbyaddress for each 3 address, but the result are all 0.00000000.Anderson 2017-11-22T09:24:08.223

Did you send money to any of those 3 addresses?Pieter Wuille 2017-11-22T09:24:28.830

No. However, I expect one of the addresses should have money because the result of RPC "listaccounts" shows there is money in the account.Anderson 2017-11-23T06:04:58.153

getreceivedbyaddress shows (surprise!) how much was received by the address. If you literally tell me you never sent money to any of them, then by definition the response should be 0. There are plenty of other ways through which the account may have been credited before.Pieter Wuille 2017-11-23T06:11:40.783

Like what kind of ways? Does it related to regtest mode?(because I am using regtest mode)Anderson 2017-11-24T02:49:29.153

1You could have received money using a getnewaddress call before any of those 3, or using the move command you can move money from other accounts (even if that makes those others negative).Pieter Wuille 2017-11-24T03:57:21.653