Make GetAvailableCredit run GetHash() only once per transaction.

Backport bitcoin/bitcoin#3973 as it brings some nice performance improvements, even to the point where apparently some wallets seemed to be stuck before.