Port signature-code simplifications and fixes from Namecoin

This patch ports over a merged pull request from Namecoin, that simplifies the transaction signing code.  It also fixes signing of raw transactions for atomic name trading, although I'm not sure how relevant that for Huntercoin is.