This is an alternative to #4283 and #4292.
It introduces a CMutableTransaction (which is just a struct, and only has GetHash() as utility method (which does not cache), next to CTransaction (which becomes immutable with a cached hash).
To keep the diff small, there are implicit conversions between CMutableTransaction and CTransaction. That may lead to unexpected low performance perhaps, but CMutableTransaction is only ever used in places that don't require performance (block building, wallet, tests); in particular, note that there is no CMutableTransaction anywhere in main.