Strictly hash what is going to be signed

Continues #4694.
Again, more important than the optimization, I think the end result is more readable.
It could be a little bit nicer by joining SignHash and Sign, but then multisig's performance would be hurt.