ParseMoney checks for a maximum number of digits before the dot, returning invalid if that is exceeded, supposedly guarding against overflow. However, this amount is set far too lenient (14) making it possible to overflow from positive into negative integer values:
10 9999999999.99999999 -> 9999999999999999999
11 99999999999.99999999 -> -8446744073709551617
...
This commit sets the maximum number of digits before the dot to 10, the maximum safe value. It also adds unit tests for various functions in util.cpp/util.h and base58.