Input selection algorithm

Rebased to vp-withdrawal.

Note I had to make some minor changes to make the test run again.

Also the createInputs and createInputsStore needs to be cleaned up. They are both taking a store right now and especially the createInputsStore name is misleading.
It'd be nice to describe what does it mean for one element to be smaller than the other here. The first thing that comes to my mind is the amount, but that's clearly not the case.