Fix bug in transaction_builder

Sometimes the builder generated a bad transaction that overwithdrew from
a balance. This is now fixed.