Can you reliably reproduce the issue?
Yes
If so, please list the steps to reproduce below:
% bitcoin-cli listtransactions '*' 2 error: couldn't parse reply from server
Expected behaviour
JSON being printed on console
Actual behaviour
JSON-PARSER in bitcoin-cli complains about invalid JSON received from bitcoind
What version of bitcoin-core are you using?
% bitcoin-cli --version Bitcoin Core RPC client version v0.13.1.0-g03422e5`
What is the last known version where listtransactions was working
The problem was discovered after upgrading nodes from 0.11.2 to 0.13.1
Why does this happen?
The wallet.dat was used since the 0.3.XX days of Bitcoin Core and upgraded over time. Some old TXs in that wallet.dat contain comments with non-ASCII chars encoded as latin1.
In this case it's the German Umlaut ü encoded as 0xFC (latin1) instead of 0xC3BC (UTF8).
bitcoind passes the comment in it's JSON response to bitcoin-cli without transformation, so the parser in bitcoin-cli complains about the latin1 representation of that character.
JSON must to be used with UTF8 encoding.
tcpdump confirms that the problem only occurs with TXs with non-utf8 special chars in their comments.
Skipping the TXs with the problematic comments works fine:
% bitcoin-cli listtransactions '*' 1 2 (...)
Does dumping wallet.dat with db_dump, modifying the dump file and db_load work as a workaround?
Yes.
Stop bitcoind, make a backup of your wallet.dat file.
db_dump -p -f dump.txt wallet.dat
grep -F comment dump.txt | perl -p -e 's#^.*comment(.*?)\\0b.*$#$1#'
# this will output all your TX comments to inspect visually before modifying
vim dump.txt
db_load -f dump.txt new.dat
mv wallet.dat wallet.dat.orig
mv new.dat wallet.dat
Problem: grep from above doesn't find all your comments. So there might still be comments left with latin1-encoded chars.
Make 100% sure to replace the special chars only in your comments. Do not use search/replace! Replace each 1 byte char with exactly 1 byte ASCI char.
In my case I replaced \fc with u (German ü --> u)
If you change the length of the string by replacing one special char with more than 1 char, you will get errors like the following on next start of bitcoind:
2016-11-15 17:29:55 init message: Loading wallet... Warning: Error reading wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect.
What's the best way to handle this?