Depends on #29524
This is an alternative to #29539 since the race condition documented there should be fixed by #29524. The race condition was discussed here. If the race is not possible we can cache this check for non-segwit blocks (= no expected witness) as well.