Total money limit test

Added bounds check by @il--ya.

Updated-by: Wladimir van der Laan <laanwj@gmail.com>
Merge pull request #3768

fecba4e Total money limit test (Pieter Wuille)