Motivation
CCoinsViewDB::Cursor() caches the first coin key after seeking to the coin
prefix. It checked that the underlying LevelDB iterator was valid, but ignored
whether deserializing the first key succeeded.
CCoinsViewDBCursor::Next() already treats a failed key decode as an invalid
cursor. The initial cursor setup should do the same.
Change
Make CCoinsViewDB::Cursor() mark the cursor invalid if the first key cannot
be decoded.
Add a regression test covering a malformed first coin key.
Test
cmake --build build --target test_bitcoin
build/bin/test_bitcoin --run_test=coins_tests_dbbase