Based on IRC talks, renamed RPC_INVALID_ADDRESS_OR_KEY to RPC_NOT_FOUND and made getblockhash return NOT_FOUND when block is above the current height.
Some chat excerpts, which started earlier on the fact the error code changed in 10.x for out of range getblockhash requests:
<wumpus> RPC_INVALID_PARAMETER = -8, //! Invalid, missing or duplicate parameter
<wumpus> that's a strange error code to return for a non-existing block
* splix has quit (Remote host closed the connection)
<dermoth> https://github.com/bitcoin/bitcoin.git
<wumpus> are you providing a valid hash?
<dermoth> oops
<dermoth> 2ffdf21ce39fc3133fc
<dermoth> that's the commit
* Aido (~Aido@178.167.130.193.threembb.ie) has joined #bitcoin-dev
<dermoth> parameter is a block number, app used to rely on error -1 to know when it reached the most recent block
<wumpus> -1 is the general error, -8 is a more specialized one
<dermoth> I see
* hsmiths has quit (Quit: END OF LINE)
<gmaxwell> error: {"code":-8,"message":"Block height out of range"}
<wumpus> I think a NOT_FOUND code would be more appropriate than invalid parameter (which hints at a parse error),but don't be afraid I won't change it again...
<dermoth> agreed
<wumpus> at least the message is clear
and later on...
<dermoth> closest error IMHO, in existing code, is RPC_INVALID_ADDRESS_OR_KEY
<wumpus> indeed. We've been using that as a NOT_FOUND.
<wumpus> maybe renaming it would be an idea
<wumpus> as said, those error names are back-projected by me, the original codebase used bare numbers without any explanation
<dermoth> would you keep the current one as an alias? I can submit a pr
<wumpus> yes, good idea
<dermoth> if (nHeight < 0... should be NOT FOUND too?
<dermoth> I see where the invalid param comes from, maybe split it up then
<wumpus> bleh.
<wumpus> see why this was never addressed? you lift it in one place, and notice the whole fabric is coming apart :-)
<wumpus> I mean I'm sure RPC_INVALID_ADDRESS_OR_KEY is also used in many cases where it really means RPC_INVALID_PARAMETER
<wumpus> before you know it, you're breaking the entire API
* abossard (~andre@46.140.123.2) has joined #bitcoin-dev
<wumpus> (and maybe that's for the best, but then it will be a fully fledged RPC return values redesign, and you would have accomplished exactly what you were coming here to complain about in the first place - hehe)
<wumpus> but maybe there's a middle way, I don't know, thanks for looking into it.
The change has been tested with the backward-compatible alias commented out:
<dermoth> wumpus, tested ok
<dermoth> $ ~/bitcoin/bitcoin/bin/bitcoin-cli getblockhash -1
<dermoth> error: {"code":-8,"message":"Negative block height"}
<wumpus> great, time to submit a PR then
<dermoth> $ ~/bitcoin/bitcoin/bin/bitcoin-cli getblockhash 361428
<dermoth> error: {"code":-5,"message":"Block height out of range"}
<dermoth> $ ~/bitcoin/bitcoin/bin/bitcoin-cli getblockhash 361424
<dermoth> 000000000000000004fd86600f6a12e5186ec18f11d7502afba3b7f7e00cae1a
<dermoth> used the 10.2 client though, but was runnign the 0.11-blarhs-dirty one (dirty bc of the commented out alias)
<dermoth> v0.11.99.0-fa19502-dirty (64-bit)