Move most of txToPairs into a new createTx func

Also changes it so that it adds new inputs incrementally as needed instead
of starting with an empty tx and adding all inputs again on each iteration.
Hmm, do you think it's worth doing that? I like having addOutputs() as a separate function because createTx() is already rather long and it allows us to more easily test that code as we can call addOutputs() directly. Currently there's only one test for addOutputs() but it's significantly simpler than the createTx() ones.