As such a feature get requested a lot (#16317, #14858 and #8457), I’ve implemented it into a new RPC call called getblockbyheight
as it was discussed in #16317
In the past this feature got requested for the getblock
command but it isn’t a good idea to interpret a string as a number because it breaks API consistency.
The function is basically just a duplicate of getblock
with the exception that it gets the hash by the height (first parameter) and not by the hash as a parameter.
It also checks if the block exists by comparing the height with the total height or if the block is negative.
EDIT: I improved the code with the help of fqlx so it no longer contains some of the getblock legacy.