This fixes a case where migratewallet can reject an old wallet as corrupt. The v2 key metadata may include an extra flag byte that Core’s metadata loader leaves unread.
LoadRecords reuses its key and value streams between records. BerkeleyROCursor::Next() appends to those streams, so unread bytes from one record become part of the next and can cause a deserialization error.
Clear both streams before copying the next record, matching SQLiteCursor::Next(). This keeps the existing metadata parsing and migration code.
The regression test reads two records while leaving part of the first key and value unread, then checks that the second record replaces both outputs.
Testing on Linux:
- Without the fix, the regression fails both stream-content checks.
- With the fix, test_bitcoin --run_test=db_tests passes all tests