Why 'bitcoin-cli getreceivedbyaddress ...' always returns 0? I've already synchronized about 400.000 blocks, but every time I'm trying to get balance for specific address, e.g. first coinbase address - link:

$ bitcoin-cli getreceivedbyaddress 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX
0.00000000


It always returns 0.00000000. What am I doing wrong?

P.S. My bitcoin-cli information:

$ bitcoin-cli getinfo
{
  "version": 140200,
  "protocolversion": 70015,
  "walletversion": 130000,
  "balance": 0.00000000,
  "blocks": 396531,
  "timeoffset": -2,
  "connections": 8,
  "proxy": "",
  "difficulty": 120033340651.237,
  "testnet": false,
  "keypoololdest": 1500906189,
  "keypoolsize": 100,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "errors": ""
}
getreceivedbyaddress is a wallet RPC. It queries your own wallet for how much money it has received on that address. Arguably, the RPC should return an error if the address is not considered its by the wallet.

You can make the wallet treat addresses as its own even if it does not have the private key, by using the watch-only functionality. However, introducing a new address will require a lengthy rescan of all of history to discover the transactions.

There is no equivalent RPC that operates on the whole node, as Bitcoin Core does not maintain a full per-address index of the blockchain.

I filed an issue here: https://github.com/bitcoin/bitcoin/issues/10921