Coin control by cozz (rebased)

Rebased version of Coin Control #2343 (all changes were trivial; biggest conflicts were `uint64`->`uint64_t` and the header refactor)