Hall algebras and quantum symmetric pairs of Kac-Moody type