[chronik] Extract scripthash history lookup into its own function
Summary: This factors the code and makes it simpler. It will also be later used to compute the status for the scripthash.subscribe endpoint.
Test Plan:
./test/functional/test_runner.py chronik_electrum_*
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Differential Revision: https://reviews.bitcoinabc.org/D18089