This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19725 | core#19725]] [5/5]
https://github.com/bitcoin/bitcoin/pull/19725/commits/a512925e19a70d7f6b80ac530a169f45ffaafa1c
Depends on D10374 and D????? (TODO: update release-notes.md and rebase)D10376