<!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->
<!-- Describe the issue -->
When using listsinceblock with a target_confirmations greater than the current block count, it returns "0000000000000000000000000000000000000000000000000000000000000000" as lastblock, which makes the method fail when using that value as blockhash
Expected behavior
<!--- What behavior did you expect? -->
The method shouldn't throw an error for a return value that is supposed "to feed back into listsinceblock the next time you call it"
Actual behavior
<!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->
RPC returns error code -5, "Block not found"
To reproduce On a pristine node where "blocks" is currently at 0, call listsinceblock '' 6, it will return "0000000000000000000000000000000000000000000000000000000000000000" as lastblock, and on next call (listsinceblock "0000000000000000000000000000000000000000000000000000000000000000" 6 it will throw an error
<!--- How reliably can you reproduce the issue, what are the steps to do so? -->
System information
<!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->
<!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->
<!-- GUI-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->
<!-- Any extra information that might be useful in the debugging process. -->
<!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->
It can be reliable reproducible without any extra steps
Proposed solution Returning the genesis block hash when target_confirmations exceeds the current block count
Note: This is particularly useful on regtest, as on mainnet you would need to call with "640645" (as of now) to get the described issue, but on a pristine regtest even using a value as low as 2 makes the returned value unsuitable for next calls.