Add a wrapper over caching input check.
Summary:
This is another backport comming from Core's PR10192. getting these wrong would cause invalid information to be cached.
Depends on D530
Test Plan:
make check ../qa/pull-tester/rpc-tests.py
Reviewers: freetrader, CCulianu, #bitcoin_abc, dagurval
Reviewed By: #bitcoin_abc, dagurval
Differential Revision: https://reviews.bitcoinabc.org/D531