This is a backport of [[https://github.com/bitcoin/bitcoin/pull/26684 | core#26684]]
with renaming changes:
https://github.com/bitcoin/bitcoin/pull/31490/commits/34f9a0157aad7c10ac364b7e4602c5f74c1f9e20
and additional includes from core#30716
Depends on D18952