If the miner code is faulty and does not include any transactions in a block,
the code segfaults when it tries to access block transactions. Instead, add a
check that safely aborts the process.
This is a backport of core#21121 [2/4]
https://github.com/bitcoin/bitcoin/pull/21121/commits/a2d908e1daa1d1be74568bd7d1d04b724da7d79c