Change amounts could be negative after deducting the cost of the extra
change output; floor them at zero. Move the assertion to the main
code. Simplify rounding logic.
Bucketing is generalization of coin chooser logic that makes it easy
to implement other algorithms.
- Put core coin chooser functionality in base class.
- Specialize derived class to implement classic electrum algorithm of
oldest coins first. One bucket per output.
No intended change in behaviour.
Coin chooser now sorts the coins as it wants; remove redundant sorting
from get_spendable_coins().
This has several advantages. Fee calculation is now very fast,
as we don't need to keep reserializing the tx. Another is that
we can reason about the fees after adding a change output without
having to add it, recalculate the tx fee, and remove it again.