backports four commits from core PR13033:
f90c3a62f [index] TxIndex method to wait until caught up.
70d510d93 [index] Allow TxIndex sync thread to be interrupted.
94b4f8bbb [index] TxIndex initial sync thread.
34d68bf3a [index] Create new TxIndex class.
Depends D2901