This is a small subset of changes taken from #10785, fixing a few of the craziest constness violations in the serialization code.
CWalletTx currently serializes some of its fields by embedding them in a key-value mapValue, which is modified (and then fixed up) even from the Serialize method (for which mapValue is const). CAccountingEntry goes even further in that it stores such a map by appending it into strComment after a null char, which is again later fixed up again.
Fix this by splitting the serialization and deserialization code, and making the serialization act on a copy of mapValue / strComment.