Backport of #24498 to 22.x branch
This was already backported to the 23.x branch in #24511, but vasild discovered the issue can affect 22.x as well #15936 (comment):
While testing this, 22.x crashes if
settings.jsoncontains"prune": 1234due to #24498 which was fixed in 23.0. So, if this PR is included in 24.x and a user upgrades to 24.x and then downgrades to 22.x his 22.x would crash at startup.
It's not very important to backport this to 22.x because I can work around the issue other ways, but I do see 22.x is listed as an active branch https://github.com/bitcoin/bitcoin/branches, so if there is another 22.x release, it would be nice to have this fix and not have a wonky uncaught univalue exception waiting to be hit